Skip to main content


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 17:35 Go to next message
Mitesh Pandey is currently offline Mitesh PandeyFriend
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 12:33 Go to previous message
Mitesh Pandey is currently offline Mitesh PandeyFriend
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: Tue Apr 23 17:20:26 GMT 2024

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

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

Back to the top