Why would Hibernate ignore package-info.java?

后端 未结 4 2096
误落风尘
误落风尘 2021-01-06 16:29

I\'m trying to use Hibernate @TypeDef annotation on a package level, exactly as it is described in the Hibernate documentation. I\'m using Hibernate 3.6 and

相关标签:
4条回答
  • 2021-01-06 17:02

    For Hibernate 4, you have to add

    <mapping package="com.foo.bar.thepackage">
    

    to your Hibernate config file.

    0 讨论(0)
  • 2021-01-06 17:06

    I believe this is due to a bug in Spring, where it doesn't scan the annotations in package-info, but only those on classes annotated with @Entity, @Embeddable, or @MappedSuperclass. See https://jira.springsource.org/browse/SPR-8589.

    0 讨论(0)
  • 2021-01-06 17:10

    You probably need to add a

    <resource package="com.foo.bar.thepackage"/>
    

    to your Hibernate config file, or to call configuration.addPackage("com.foo.bar.thepackage").

    0 讨论(0)
  • 2021-01-06 17:17

    If using JPA, using

    <class>com.foo.bar.thepackage</class>
    in the persistence.xml also should work.

    0 讨论(0)
提交回复
热议问题