Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Persistence(Primary key value assign to another column)
Persistence [message #842869] Thu, 12 April 2012 13:35 Go to next message
Mitesh Pandey is currently offline Mitesh Pandey
Messages: 7
Registered: March 2012
Junior Member
Hi
I have an entity like

@Entity
public class Customer
{

@ID
@column(name="CustomerID")
private int customerID;

@column(name="CustID")
private int custID;

}

where customerID is a primary key column and hence it is annotated with Id
and custID is just another column

Requirement is that when customer object is persisted, customerID and custID should have the same value. Now, generation of ID is left to JPA.

How can i set CustID with the same value as CustomerID in a single database trip? Is there any annotation which can help me achieve it?
Re: Persistence [message #843849 is a reply to message #842869] Fri, 13 April 2012 08:33 Go to previous message
Mitesh Pandey is currently offline Mitesh Pandey
Messages: 7
Registered: March 2012
Junior Member
Hi All,

@PrePersist did the job

Pretty easy approach. Should have thought of it even before posting the question
Previous Topic:PK Violation on Many-to-One Child Record
Next Topic:Running JPA 1 & 2 in same Process
Goto Forum:
  


Current Time: Fri Aug 01 22:40:39 EDT 2014

Powered by FUDForum. Page generated in 0.01952 seconds