5 Replies Latest reply on May 20, 2008 9:15 AM by rhodan76

    Hibernate specific @Index annotation is ignored

    winterer

      Hi!

      I've some EJB3 beans annotated with the hibernate specific annotation @index.
      Unfortunately, this annotation is ignored when the jar file is deployed (database: MySQL), no matter if the schema is already existing or not.

      Is this a bug?

        • 1. Re: Hibernate specific @Index annotation is ignored
          rhodan76

          This bug(?) seems to further exist. Anyone got @Index working inside jboss ?

          • 2. Re: Hibernate specific @Index annotation is ignored
            jaikiran

            Please post the version of JBoss and Java, you are using. Also, post the code where @Index is used and also the persistence.xml file.

            While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

            • 3. Re: Hibernate specific @Index annotation is ignored
              rhodan76

              We are using:

              Jboss 4.2.2 GA
              Hibernate EntityManager 3.2.1.GA
              Hibernate Annotations 3.2.1.GA
              Hibernate 3.2.4.sp1

              Following example for defining the index:

              @Column
              @org.hibernate.annotations.Index(name = "test_idx")
              public String getUserName() {
               return this.userName;
              }


              Bug seems to be related to the persistence.xml entry:
              <property name="hibernate.hbm2ddl.auto" value="create-drop" />


              Index generation ONLY works when hibernate.hbm2ddl.auto is set to "create-drop", in any other case the index is NOT created. I'm shure, anybody understands, that 'create-drop' is not an appropriate value for production systems.

              • 4. Re: Hibernate specific @Index annotation is ignored
                jaikiran

                 

                "Rhodan" wrote:

                Index generation ONLY works when hibernate.hbm2ddl.auto is set to "create-drop" in any other case the index is NOT created.I'm shure, anybody understands, that 'create-drop' is not an appropriate value for production systems.


                It works with hibernate.hbm2ddl.auto = "create" too.

                <properties>
                 <property name="hibernate.hbm2ddl.auto" value="create"/>
                 </properties>
                



                As for why, it doesn't work with "update", see this http://www.hibernate.org/119.html#A10




                • 5. Re: Hibernate specific @Index annotation is ignored
                  rhodan76

                  Sometimes it's mystical. I could swear i tested with "create" and it was not working. But now i checked again and as you said it worked with "create".

                  Thank you !