Results 1 to 9 of 9

Thread: AnnotationSessionFactoryBean and annotatedPackages prop

Hybrid View

  1. #1

    Default 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 :

    <property name="annotatedClasses">
    <list>
    <value>me.model.Customer</value>
    </list>
    </property>

    But this one really doesn't :

    <property name="annotatedPackages">
    <list>
    <value>me.model</value>
    </list>
    </property>

    Is it a known problem ? My model classes are NOT in a separate .jar, btw.

    Thanks

  2. #2
    Join Date
    Dec 2006
    Location
    Belgium
    Posts
    20

    Default

    I experienced the same problem (but using the cfg.xml).
    Would like to know the answer aswell.

  3. #3
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Quote Originally Posted by Wheazel View Post
    I experienced the same problem (but using the cfg.xml).
    Would like to know the answer aswell.
    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.

  4. #4
    Join Date
    Dec 2006
    Location
    Belgium
    Posts
    20

    Default

    Excellent answer.
    Thx a lot.

    To be honest, the name is misleading.

  5. #5
    Join Date
    Feb 2007
    Posts
    2

    Default Hibernate annotatedPackages entity names

    Hi!

    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

    Thank you,
    Uwe Kubosch
    Norway

  6. #6
    Join Date
    Sep 2010
    Location
    Cork, Ireland
    Posts
    16

    Default

    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:
    <property name="packagesToScan">
    <list>
    <value>foo/bar/*/model</value>
    </list>
    </property>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •