OpenJPA
  1. OpenJPA
  2. OPENJPA-1556

Exception thrown on first use of @Strategy in @Embeddable classes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-beta2
    • Fix Version/s: 2.0.0-beta3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Mac OS X 10.6, Maven 2.2.x, Spring 3.0

      Description

      I have an entity (SimpleEntity) which references an ElementCollection (ChildOne.class). There is a @Strategy annotation on a field within the embeddable class. The first time a query is built for the entity, an exception is thrown:

      <openjpa-2.0.0-beta2-r422266:915978 fatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to map "com.example.ChildOne.address" failed: the owning entity is not mapped.
      at org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:628)
      at org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:558)
      at org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:178)
      at org.apache.openjpa.jdbc.meta.strats.HandlerStrategies.map(HandlerStrategies.java:65)
      at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:81)
      at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:146)
      ... etc. ...

      If the @Strategy is not present, everything works fine. If the exception is intentionally triggered, subsequent use is successful.

      Google suggests that this behavior has been seen before <http://marc.info/?l=geronimo-user&m=121545735018232&w=2> and <http://issues.apache.org/jira/browse/OPENJPA-524>, though there appears to have been no resolution in either case and this differs by use of @ElementCollection.

      1. openjpa1556.tar.zip
        8 kB
        Jerry Carter
      2. OPENJPA-1556.patch
        2 kB
        Fay Wang

        Issue Links

          Activity

          Jerry Carter created issue -
          Hide
          Jerry Carter added a comment -

          The attached Eclipse project uses Maven for the builds. Import into Eclipse and build as Maven install. There will be an exception thrown from TestSimpleDAO::testCreateEntity(). Readding the commented lines as the start of the function will cause the exception to be caught and ignored on the first pass with all subsequent interactions succeeding.

          Show
          Jerry Carter added a comment - The attached Eclipse project uses Maven for the builds. Import into Eclipse and build as Maven install. There will be an exception thrown from TestSimpleDAO::testCreateEntity(). Readding the commented lines as the start of the function will cause the exception to be caught and ignored on the first pass with all subsequent interactions succeeding.
          Jerry Carter made changes -
          Field Original Value New Value
          Attachment openjpa1556.tar.zip [ 12438310 ]
          Fay Wang made changes -
          Assignee Fay Wang [ faywang ]
          Fay Wang made changes -
          Attachment OPENJPA-1556.patch [ 12438343 ]
          Fay Wang made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.1.0 [ 12314542 ]
          Resolution Fixed [ 1 ]
          Fay Wang made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Donald Woods made changes -
          Fix Version/s 2.0.0 [ 12314019 ]
          Fix Version/s 2.1.0 [ 12314542 ]
          Hide
          Oliver Ringel added a comment -

          the same exception occurs if you add the @Strategy annotation on a field of an @Embeddable or @MappedSuperclass (not part of an @ElementCollection).
          The attached patch does not fix the problem.

          To be more concrete. I try to change the default enum handling using an own EnumValueHandler. The Handler is working if you add
          the Strategy to the @Entity. Adding the field to a @MappedSuperclass leads to the above exception.

          @javax.persistence.Entity
          @javax.persistence.Table(name = "TESTENTITY")
          public class TestEntity extends TestEntityBase

          { ... }

          @MappedSuperclass
          public abstract class TestEntityBase

          { @Column(name = "TESTENUMSIMPLE") @Enumerated(javax.persistence.EnumType.STRING) @Strategy("jpa.test.domain.EnumStrategy") private TestEnumSimple testEnumSimple; ... }

          You get the same Exception if you add the @Strategy to a @Embeddable and I also tried a own StringValueHandler with the same result.

          Show
          Oliver Ringel added a comment - the same exception occurs if you add the @Strategy annotation on a field of an @Embeddable or @MappedSuperclass (not part of an @ElementCollection). The attached patch does not fix the problem. To be more concrete. I try to change the default enum handling using an own EnumValueHandler. The Handler is working if you add the Strategy to the @Entity. Adding the field to a @MappedSuperclass leads to the above exception. @javax.persistence.Entity @javax.persistence.Table(name = "TESTENTITY") public class TestEntity extends TestEntityBase { ... } @MappedSuperclass public abstract class TestEntityBase { @Column(name = "TESTENUMSIMPLE") @Enumerated(javax.persistence.EnumType.STRING) @Strategy("jpa.test.domain.EnumStrategy") private TestEnumSimple testEnumSimple; ... } You get the same Exception if you add the @Strategy to a @Embeddable and I also tried a own StringValueHandler with the same result.
          Hide
          Jerry Carter added a comment -

          Oliver: Interesting. Not sure what the protocol is for this project, but you might open a new JIRA report and link back to this one.

          Show
          Jerry Carter added a comment - Oliver: Interesting. Not sure what the protocol is for this project, but you might open a new JIRA report and link back to this one.
          Oliver Ringel made changes -
          Link This issue relates to OPENJPA-1570 [ OPENJPA-1570 ]
          Jerry Carter made changes -
          Link This issue is related to OPENJPA-1574 [ OPENJPA-1574 ]
          Donald Woods made changes -
          Fix Version/s 2.0.0-beta3 [ 12314857 ]
          Fix Version/s 2.0.0 [ 12314019 ]

            People

            • Assignee:
              Fay Wang
              Reporter:
              Jerry Carter
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development