Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Bug 241765 - JPA 2.0 Derived identities

Hello Pinaki,
    You can confirm the EclipseLink version by setting the log level to INFO and looking for the EclipseLink version string.  In the logs you posted you are using version 1.1.0 not 2.0.  There must be a runtime environment classpath issue.

You can download the latest EclipseLink from http://www.eclipse.org/eclipselink/downloads/
You can decompile/look at the machine code of the org.eclipse.persistence.Version.class file if you have any doubts that the logged version is incorrect.
--Gordon

Pinaki Poddar wrote:
Hi Gordon,
  I downloded from [1]. Thinking that is the latest. The website mentions
that the bundle is at revision 
eclipselink-2.0.0.v20091127-r5931. But once you mentioned that I may be
using an old version, I notice that the error messages print a different
version number such as
   Exception [EclipseLink-30005] (Eclipse Persistence Services -
1.1.0.r3634): ....

  It is unlikely (but not impossible) that it is a build/run environmental
mistake -- I am double0checking that.

  Questions:
  1. Can you please confirm where I can downlod the latest EclipeLink
libraries? 
  2. Is there an utility that prints out the revision numbr of the library?
Or any other suggested mechanism to verify the download is at a specific
revision?  
 
  Thanks --

[1]
http://www.eclipse.org/downloads/download.php?file=/rt/eclipselink/releases/2.0.0/eclipselink-2.0.0.v20091127-r5931.zip 



Gordon Yorke wrote:
  
Hello Pinaki,
   The version of EclipseLink you are using is very old and is not JPA 2.0
compatible.  You will need to upgrade to EclipseLink 2.0
--Gordon


Pinaki Poddar wrote:
    
Hi,
  While the error message is fairly clear why it thinks the mapping
definitions are wrong, here is the JPA 2.0 spec (sec 2.4.1.1:
Specification of Derived Identities)
"If the dependent entity uses an id class to represent its primary key,
one of the two following rules must
be observed:"
  // lines ommitted
  "If an Id attribute in the entity is a many-to-one or one-to-one
relationship to a parent
entity, the corresponding attribute in the id class must be of the same
Java type as the
id class or embedded id of the parent entity (if the parent entity has a
composite primary
key) or the type of the Id attribute of the parent entity (if the parent
entity has a
simple primary key)."


  My reading is LineItem (child) having a @Id @ManyToOne PurchaseOrder
and LineItem using @IdClass(LineItemId.class) fit into the above spec
scenario. 

  Regards --

Pinaki
 

Pinaki Poddar wrote:
      
Hi,
  A typical Order-LineItem definition where LineItem uses compound,
derived identity.
Is this mapping supported in 1.1.0.r3634 or any later available
versions?

  The mapping fails with following error message (detailed stack trace
at the end)

     [java] Caused by: Exception [EclipseLink-7149] (Eclipse Persistence
Services - 1.1.0.r3634):
org.eclipse.persistence.exceptions.ValidationException
     [java] Exception Description: The composite primary key attribute
[order] of type [class domain.PurchaseOrder] on entity class [class
domain.LineItem] should be of the same type as defined on its primary
key class [domain.LineItemId]. That is, it should be of type [long].   

  
Here are the entity definitions:
 
  A "parent" entity with a simple identity of a long field 
-------------------------------------------------------------
@Entity
public class PurchaseOrder implements Serializable {
    @Id
    private long id;
}
-------------------------------------------------------------
 A "child" entity that 
   -- uses a separate Id class
   -- uses a compound identity
   -- derives part of its identity from "parent"
-------------------------------------------------------------               
  @Entity
  @IdClass(LineItemId.class)
  public class LineItem implements Serializable {
    @Id
    @ManyToOne
    private PurchaseOrder order; // field name must match the field name
in LineItem.LineItemId
    
    @Id
    @OrderColumn
    @Column(name="IDX") // index is keyword
    private int index;  // field name must match the field name in
LineItem.LineItemId
---------------------------------------------------------------
   And the separate Id class
---------------------------------------------------------------
public class LineItemId implements Serializable {
    long order;  
    int index; 

The runtime fails with the following error:


     [java] Caused by: Exception [EclipseLink-7149] (Eclipse Persistence
Services - 1.1.0.r3634):
org.eclipse.persistence.exceptions.ValidationException
     [java] Exception Description: The composite primary key attribute
[order] of type [class domain.PurchaseOrder] on entity class [class
domain.LineItem] should be of the same type as defined on its primary
key class [domain.LineItemId]. That is, it should be of type [long].
     [java]     at
org.eclipse.persistence.exceptions.ValidationException.invalidCompositePKAttribute(ValidationException.java:1082)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.validatePKClassId(MetadataDescriptor.java:1438)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.IdAccessor.process(IdAccessor.java:65)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.processAccessors(MetadataDescriptor.java:1082)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processAccessorsClassAccessor.java:636)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processAccessors(EntityAccessor.java:611)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:530)
     [java]     at
org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:446)
     [java]     at
org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:303)
     [java]     at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:838)


  
   



christopher delahunt wrote:
        
Bug 241765 - JPA 2.0 Derived identities
Checked into main.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=241765
reviewed by Gordon and Guy
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


          
        
      
    
  

Back to the top