facebook

@GeneratedValue annotation missing from generated code

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #321363 Reply

    ameelin
    Member

    Was using me4s 10 and it did not generate the @GeneratedValue (GenerationType.IDENTITY) for my mysql schema with keys set to autoincrement. Was looking into applying the customization project, but don’t have a clue what I should correct in the DataTypeTemplate(I see persistence:generatedValue). Please advise.
    (I could do this manually, but there are just too many objects)

    #321449 Reply

    cconway
    Member

    Hi ameelin,

    Unfortunately, the problem is not one that can be truly solved by modifying the code generation templates. The problem is that the metadata returned from the database doesn’t contain the information necessary to determine that a particular field is auto-incremented. In fact, the persistence:generatedValue tag that you referenced is already trying to output the @GeneratedValue (GenerationType.IDENTITY) and is unable to detect the auto increment field.

    Now if all of your key fields are auto-incremented, you could just put the desired text (@GeneratedValue (GenerationType.IDENTITY)) in the block:

    <c:if test="$field/@primaryKey = 'true'">
        <persistence:id select="$field" />
    </c:if>

    The persistence:id tag shown in the code block above outputs the @Id annotation.

    Also, if you have any compound primary keys, there is a “DataTypeKey.jet” file that will need to have the same changes made.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: @GeneratedValue annotation missing from generated code

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