Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate Annotations package scan not works package-info #86

Closed
zhanhb opened this issue Jul 21, 2015 · 6 comments · Fixed by #729
Closed

Hibernate Annotations package scan not works package-info #86

zhanhb opened this issue Jul 21, 2015 · 6 comments · Fixed by #729

Comments

@zhanhb
Copy link

zhanhb commented Jul 21, 2015

I work with spring-boot, and have no persistence.xml file, I configured a TypeDef in file package-info.java,
I set hibernate.hmb2ddl.auto to create, run the test case, the type in the database will surely be datetime, but it doesn't work with liquibase-hibernate spring connection.
here is my configuraion in the pom.xml.

<plugin>
    <!-- ... -->
    <configuration>
        <url>jdbc:mariadb://localhost:3306/oj?zeroDateTimeBehavior=convertToNull&amp;characterEncoding=UTF-8</url>
        <username>root</username>
        <password>root</password>

        <!-- see liquibase.ext.hibernate.database.HibernateSpringDatabase -->
        <!-- see org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager -->
        <referenceUrl>hibernate:spring:com.github.zhanhb.judge.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect</referenceUrl>

        <changeLogFile>${project.build.resources[0].directory}/config/liquibase/master.xml</changeLogFile>
        <diffChangeLogFile>${project.build.resources[0].directory}/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>

        <logging>debug</logging>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
        <verbose>true</verbose>
        <systemProperties>
            <logback.configurationFile>${project.build.resources[0].directory}/logback.xml</logback.configurationFile>
        </systemProperties>
    </configuration>
</plugin>

here is the codes in my package-info.java

@TypeDefs({
    @TypeDef(name = "localDateType", typeClass = org.jadira.usertype.dateandtime.threeten.PersistentLocalDate.class, defaultForType = java.time.LocalDate.class),
    @TypeDef(name = "localDateTimeType", typeClass = org.jadira.usertype.dateandtime.threeten.PersistentLocalDateTime.class, defaultForType = java.time.LocalDateTime.class),
    @TypeDef(name = "localTimeType", typeClass = org.jadira.usertype.dateandtime.threeten.PersistentLocalTime.class, defaultForType = java.time.LocalTime.class)
})
package com.github.zhanhb.judge.domain;

import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

┆Issue is synchronized with this Jira Bug by Unito

@zhanhb
Copy link
Author

zhanhb commented Jul 21, 2015

<properties>
    <asm.version>5.0.4</asm.version>
    <javassist.version>3.20.0-GA</javassist.version>
    <spring-boot.version>1.2.5.RELEASE</spring-boot.version>
    <maven.version>3.3.3</maven.version>
    <liquibase-hibernate4.version>3.5</liquibase-hibernate4.version>
    <liquibase.version>3.4.0</liquibase.version>
    <hibernate.version>4.3.10.Final</hibernate.version>
    <usertype.version>4.0.0.GA</usertype.version>
</properties>

@zhanhb
Copy link
Author

zhanhb commented Jul 21, 2015

If I put @typedefs on to any entity class, it works ok, but can it works I put it on to package-info???

@mcnaggets
Copy link

Any progress on that? I have similar issue with

@GenericGenerator(
        name = DEFAULT_GENERATOR,
        strategy = SEQUENCE_STYLE_GENERATOR,
        parameters = @Parameter(name = SEQUENCE_PARAM, value = "default_sequence")
)

on the package level

@MaksimPrabarshchuk
Copy link

+1

@lgoldstein
Copy link

+1 - Does Hibernate scan for annotations on interfaces ? As a quick workaround can we use

@TypeDefs({
    @TypeDef(name = "type1", typeClass = foo.bar.Type1),
    @TypeDef(name = "type2", typeClass = foo.bar.Type2),
    @TypeDef(name = "type3", typeClass = foo.bar.Type3)
})
public interface Marker {
     // nothing
}

@Entity
public class MyEntity implements Marker {
    private foo.bar.Type1 type1Value;

    public MyEntity() {
        super();
    }

    @Column
    public foo.bar.Type1 getSpecialType1() {
        return type1Value;
    }

    public void setSpecialType1(foo.bar.Type1 type1Value) {
        this.type1Value = type1Value;
    }
}

@fuitattila
Copy link

fuitattila commented Aug 7, 2024

I have a similar problem but with the @FilterDef annotation at package level.

For exmaple with this wont work (package-info.java):

@FilterDef(name = "deletedFilter", defaultCondition = "deleted_at IS NULL")
package hu.webdream.iunox.model;

import org.hibernate.annotations.FilterDef;

When I run from maven the liquibase:diff command it fails with this error:

[ERROR] Error setting up or running Liquibase:
[ERROR] org.hibernate.AnnotationException: Entity 'Group' has a '@Filter' for an undefined filter named 'deletedFilter'

However it works fine in my Spring application.

RookieRoll pushed a commit to RookieRoll/liquibase-hibernate that referenced this issue Dec 2, 2024
filipelautert pushed a commit to RookieRoll/liquibase-hibernate that referenced this issue Dec 9, 2024
filipelautert pushed a commit that referenced this issue Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants