Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » derived identifier of derived identifier
derived identifier of derived identifier [message #683888] Tue, 14 June 2011 15:42 Go to next message
jmilkiewicz  is currently offline jmilkiewicz Friend
Messages: 4
Registered: June 2011
Junior Member
Hi

I am using glassfish 3.1 b40 and according to what i see in glassh logs i am using
"Eclipse Persistence Services - 2.2.0.v20110114-r8831"

In my scenario i want to create an entity with 2 references to other entities, and having PK being a composite id of FK. The problem i got is when one of these references entities has a derived identifier as well (shared primary key).
To clarify, pls take a look at sample:

@Entity
public class Auction implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy=GenerationType.TABLE)
    private Long id;
}


@Entity
public class Dealer {
    @Id
    private Long id;
    @OneToOne(cascade = CascadeType.ALL)
    @MapsId
    private AppUser user;


@Entity
public class AppUser{    
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private Long userName;    
}




@Entity
@IdClass(AuctionObserverPK.class)
public class AuctionObserver implements Serializable{
    @Id
    @ManyToOne
    private Auction auction;

    @Id
    @ManyToOne
    private Dealer user;
}




public class AuctionObserverPK implements Serializable{
    private Long auction;
    private Long user;
}


So, i have a problem with mapping AuctionObserver- during deploy of my application i got:
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110114-r8831): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [Car4uPU] failed.
Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.IdAccessor cannot be cast to org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)
... 28 more
Caused by: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.IdAccessor cannot be cast to org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processId(ObjectAccessor.java:444)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:659)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:110)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processDerivedId(ClassAccessor.java:1409)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processDerivedId(EntityAccessor.java:823)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processAccessorsWithDerivedIDs(MetadataProject.java:1294)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1560)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:486)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:454)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1081)
... 27 more

If i change type of user property of AuctionObserver from Dealer to User application deploys with no problems.


Any ideas, pls.


Re: derived identifier of derived identifier [message #683979 is a reply to message #683888] Tue, 14 June 2011 19:34 Go to previous messageGo to next message
jmilkiewicz  is currently offline jmilkiewicz Friend
Messages: 4
Registered: June 2011
Junior Member
I just downloaded glassfish 3.1 final release but still face the same problem. GF 3.1 final goes with eclipse link 2.2.0 RC4.
(no subject) [message #683994 is a reply to message #683888] Tue, 14 June 2011 19:34 Go to previous messageGo to next message
jmilkiewicz  is currently offline jmilkiewicz Friend
Messages: 4
Registered: June 2011
Junior Member
I just downloaded glassfish 3.1 final release but still face the same problem. GF 3.1 final goes with eclipse link 2.2.0 RC4.
Re: (no subject) [message #684922 is a reply to message #683979] Thu, 16 June 2011 13:33 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please log a bug for the exception, you should at a minimum get a better error message. Also try the 2.3 release, the issue may have been fixed.

Remove the @MapsId, I don't think you should have that, Dealer should not have an id, just the @OneToOne to AppUser also marked as @Id. If you want both, then set one to insertable/updateable=false or use a @PrimaryKeyJoinColumn.


James : Wiki : Book : Blog : Twitter
Previous Topic:Composite Key and IN Operator
Next Topic:EclipseLink JPA: RMI cache coordination problem - cache not sync
Goto Forum:
  


Current Time: Fri Apr 19 15:10:30 GMT 2024

Powered by FUDForum. Page generated in 0.02010 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top