facebook

No GeneratedValue in JPA Reverse Engineering

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #272851 Reply

    donpark
    Member

    JPA Reverse Engineering in both 5.5 and 6.0M1 doesn’t generate @GeneratedValue annotation for primary key fields that auto_increment. Ideally, @GeneratedValue(strategy=GenerationType.IDENTITY) should be generated since I am using MySQL with TopLink JPA provider.

    I’ve looked at custom templates but this issue appears to be in code the Hibernate tool MyEclipse is apparently using for JPA reverse engineering.

    Since there is no apparent way to inject field generation strategy hint using JPA annotations without having to edit reverse engineered files every time, value of JPA Reverse Engineering is reduced to a one-time use tool.

    #272852 Reply

    donpark
    Member

    Nevermind. I found the workaround. “Custom templates” option in the wizard threw me off trail but searching the web let me to hibernate-reverse-engineering configuration stuff which I noted is what jpa.reveng.xml file is. I changed the file by adding the following to each table element with auto_increment surrogate primary key.

    <primary-key>
    <generator class=”identity” />
    <column name=”id” />
    </primary-key>

    this change generated correct GeneratedValue annotation (broke concrete classes though because abstract pojo class changed too much).

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: No GeneratedValue in JPA Reverse Engineering

You must be logged in to post in the forum log in