4 Replies Latest reply on Apr 6, 2007 3:54 PM by Andy Dennis

    seam-gen and @GeneratedValue

    Andy Dennis Newbie

      Usng the new-entity switch for seam.bat generates an entity with the above annotation on the id field. However I don't seem to be able to get the same behavior with generate-entities. Is there something I should do in the database schema for this to happen? Currenly using mysql 5 and the id field is set as auto incrementing.

      Otherwise this tool is really sweet!


        • 1. Re: seam-gen and @GeneratedValue
          Gavin King Master

          Currently the Hibernate Tools core is not able to detect autoincrement columns (there is nothing in the standard JDBC metadata for it), and it will never be possible to detect columns that are assigned from a sequence value.

          However, max is going to get the autoincrement detection working for at least MySQL ASAP.

          • 2. Re: seam-gen and @GeneratedValue
            Andy Dennis Newbie

            Thanks Gavin and Max.
            I'm looking at seeing how I can design the sight around what you generate without tweaking the generated stuff, java and xhtml. That way it should make changes to the datamodel as painless as possible.

            • 3. Re: seam-gen and @GeneratedValue
              Alex Narinsky Newbie


              I have the same problem with generated entities.

              Did you find any workaround?

              My database was generated by Hibernate using org.hibernate.tool.hbm2ddl.SchemaExportTask

              Id supposed to be auto generated. However, when I add @GeneratedValue to the Id getter I am getting the exception on startup:
              ObjectName: persistence.units:ear=spot4.ear,unitName=spot4
              State: FAILED
              Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Missing sequence or table: hibernate_sequence
              I Depend On:

              With the old variant of Hibernate this auto sequence generated worked with the following annotation used in Doclet:
              * @hibernate.id column="ID" generator-class="increment" unsaved-value="0"

              Thank you!

              • 4. Re: seam-gen and @GeneratedValue
                Andy Dennis Newbie

                Sorry, project isn't currently critical so I'm holding on until seam-gen can do the work. My fix would be to add the annotation, as you suggest. The other thing is to check the persistent configuration. I think mine ended up with validate in one of the properties in persistence.xml, which I would probably change to update and allow the code then to regenerate the schema for me. It may be that you'll need to check out the @GeneratedValue parameters to make sure that you select the appropriate option for the way that your database works with sequence numbers. The default may not be suitable for your set up.