Why does Hibernate ignore package-info.java?

I am trying to use the Hibernate @TypeDef annotation at the package level, exactly as described in the Hibernate documentation . I am using Hibernate 3.6 and Spring 3.0.7 . Compiling the code and package-info.class is in the classpath, but still it does not appear in Hibernate.

If I put @TypeDef at the class level, it works, but not if I put in package-info . I tried Google but did not find anything useful.

Thanks!

+3
source share
4 answers

You probably need to add

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

into your Hibernate configuration file or call configuration.addPackage ("com.foo.bar.thepackage") .

+6
source

For Hibernate 4 you need to add

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

into your Hibernate configuration file.

+2
source

When using jpa use

  <class> com.foo.bar.thepackage </class> 
in persistence.xml should also work.
+2
source

I believe this is due to a bug in Spring where it does not scan annotations in package information, but only those that were in classes annotated with @Entity, @Embeddable or @MappedSuperclass. See https://jira.springsource.org/browse/SPR-8589 .

+2
source

Source: https://habr.com/ru/post/982081/


All Articles