Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » PK Violation on Many-to-One Child Record
PK Violation on Many-to-One Child Record [message #842790] Thu, 12 April 2012 15:58
Jason Hodge is currently offline Jason HodgeFriend
Messages: 7
Registered: April 2012
Junior Member
I have an entity, Journal, which has a Many-to-One relationship with a second entity, DeliveryType. The mapping is expressed as:


@Entity
@Table(name = "JOURNAL")
public class Journal implements Serializable, Comparable<Journal> {

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "DELIVERY_TYPE_ID")
private DeliveryType deliveryType;

//...excluded...
}


DeliveryType is merely a static look-up table with 6 values. It should never be persisted. Its ID should just be written as a foreign key to the Journal table.


@Entity
@Table(name="DELIVERY_TYPE")
@NamedQueries({
@NamedQuery(name=DeliveryType.DISPLAYABLE,
query="select s from DeliveryType s where s.isDisplayable = 'Y'" ),
@NamedQuery(name=DeliveryType.DUPE_CHECK,
query="select s from DeliveryType s where lower(s.description)=lower(:description)" )
})
public class DeliveryType implements Serializable, Comparable<DeliveryType> {

//...omitted...
}


The project previously used TopLink, but I don't think the conversion is responsible for the odd behavior. The problem is that when parent entity, Journal is changed (assigned a different DeliveryType), EclipseLink seems to think that the DeliveryType object is a brand new object and does an INSERT op on it, causing a primary key violation. This is suddenly happening with many of our look-up-only entities.

Is there some kind of caching going on that detaches these entities from the PersistenceManager somehow? Why does EclipseLink think they are new and try to save them?

Details:
===============
EclipseLink 2.3
JPA 2.0
JDeveloper
WebLogic 10.3.5
Oracle 9, Thin Driver, Non-XA DataSources
Sun JDK 1.6
Previous Topic:PK Violation on Many-to-One Child Record
Next Topic:Persistence
Goto Forum:
  


Current Time: Sat Oct 05 01:24:23 GMT 2024

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

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

Back to the top