glassfish
  1. glassfish
  2. GLASSFISH-386

When class is specified both in mappings.xml and annotated, TopLink reports no primary key specified.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.0pe
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      386

      Description

      In the attached appclient jar file, I have a persistence unit which refers to a
      mapping file. The mapping file specifies the entity class UserCredential.class
      which is also annotated as @Entity and it has a field called name which is
      annotated as @Id as below:

      @Entity
      public class UserCredential implements java.io.Serializable {
      @Id // name is the PK of this entity.
      private String name;

      private String password;
      }

      When I try to verify this, I get the following message:

      Exception Description: Entity class [class example.entity.UserCredential] has no
      primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.

      Please note that my mappings.xml file does not specify access type, so I expect
      the access type to be defaulted to field as one of the field is annotated.

      When I remove the mapping file, this error goes away.

      Thanks,
      Sahoo

        Activity

        Hide
        Sanjeeb Sahoo added a comment -

        Created an attachment (id=125)
        test case along with README

        Show
        Sanjeeb Sahoo added a comment - Created an attachment (id=125) test case along with README
        Hide
        Sanjeeb Sahoo added a comment -

        Created an attachment (id=126)
        test case along with README

        Show
        Sanjeeb Sahoo added a comment - Created an attachment (id=126) test case along with README
        Hide
        Sanjeeb Sahoo added a comment -

        Attachment #125
        (https://glassfish.dev.java.net/nonav/issues/showattachment.cgi/125/issue_386.zip)
        does not use mapping xml file. So it passes verifier.
        Attachment #126
        (https://glassfish.dev.java.net/nonav/issues/showattachment.cgi/126/issue_386.zip)
        uses mapping xml and it fails verifier.

        Please also note that this is not a verifier bug. It is a bug in TopLink
        verification code.

        Show
        Sanjeeb Sahoo added a comment - Attachment #125 ( https://glassfish.dev.java.net/nonav/issues/showattachment.cgi/125/issue_386.zip ) does not use mapping xml file. So it passes verifier. Attachment #126 ( https://glassfish.dev.java.net/nonav/issues/showattachment.cgi/126/issue_386.zip ) uses mapping xml and it fails verifier. Please also note that this is not a verifier bug. It is a bug in TopLink verification code.
        Hide
        shanchen added a comment -

        I tried it in our SE test framework and it appears fixed.

        Show
        shanchen added a comment - I tried it in our SE test framework and it appears fixed.
        Hide
        Sanjeeb Sahoo added a comment -

        Verified with the attached test case. Note, the test case had to be changed as
        it was not using version attribute in xml files.

        Show
        Sanjeeb Sahoo added a comment - Verified with the attached test case. Note, the test case had to be changed as it was not using version attribute in xml files.

          People

          • Assignee:
            tware
            Reporter:
            Sanjeeb Sahoo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: