Jan 12th, 2007, 05:01 AM
AnnotationSessionFactoryBean and annotatedPackages prop
Hi, using Spring2.0 and Hibernate3.2.1.GA, whenever I set the annotatedPackages prop on a AnnotationSessionFactoryBean, it does'nt see my annotated @Entity classes.
However, this works :
But this one really doesn't :
Is it a known problem ? My model classes are NOT in a separate .jar, btw.
Jan 12th, 2007, 05:37 AM
I experienced the same problem (but using the cfg.xml).
Would like to know the answer aswell.
Jan 12th, 2007, 10:32 AM
AnnotatedPackages property is not meant to be used instead of annotatedClasses, it does something else (it allows you to define a class with package-level annotations). Hibernate does not provide a way to automagically find all annotated classes in a package.
Originally Posted by Wheazel
Jan 13th, 2007, 10:56 AM
Thx a lot.
To be honest, the name is misleading.
Feb 2nd, 2007, 08:31 AM
Hibernate annotatedPackages entity names
I am using the annotatedPackages property and it does indeed magically find all my Entity classes and map them correctly to the database tables.
However, the entity names are set to the fully qualified names of the entity classes instead of the simple unqualified name of the class which is the default using annotatedClasses and is atetd to be the default for the Entity annotation.
Explicitly setting the entity name to the simple name of the class does not work either. The entity is still mapped using the fully qualified name of the class.
Can anybody help me with this? All my queries are written using the simple name of the entity class, and the fully qualified class name is MUCH to long to write everywhere
Nov 14th, 2011, 11:25 AM
Although this question was asked a loong time ago, here is the answer. Don't use "annotatedPackages" but rather "packagesToScan". And the pattern to use is "directory" based (not package based), so for example: