Announcement Announcement Module
Collapse
No announcement yet.
AnnotationSessionFactoryBean and annotatedPackages prop Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    I experienced the same problem (but using the cfg.xml).
    Would like to know the answer aswell.

    Comment


    • #3
      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.

      Comment


      • #4
        Excellent answer.
        Thx a lot.

        To be honest, the name is misleading.

        Comment


        • #5
          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

          Comment


          • #6
            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>

            Comment


            • #7
              Wow! That IS a long time ago. Thanks!

              Comment


              • #8
                And back in that day, there was no packagesToScan property in the AnnotationSessionFactoryBean. Someone did extend that class and posted it online in a blog entry that almost everyone copied. So I think that is how it really got into that class as of Spring 3.0

                Mark

                Comment


                • #9
                  So nice to see people returning and adding valuable information to an old topic.

                  The packagesToScan was exactly what I was looking for.

                  Thanks

                  Comment

                  Working...
                  X