Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » entitymanager problem merge(merge() problem)
entitymanager problem merge [message #1064551] Wed, 19 June 2013 20:45 Go to next message
kamal na is currently offline kamal naFriend
Messages: 3
Registered: June 2013
Junior Member
I have a problem with the entitymanager
times and need your help.
I just want to save time and merge two tables each time
the tables have 1to n relationship
my trouble at the entitymsnsger.merge (table1). tabellle1 which is updated. table2 but does not update

many thanks for your help

public void save(Object1 object1, List<Object2> object2List) {
// TODO Auto-generated method stub
try {

Tabelle1 tabelle1 = new Tabelle1();


List<Tabelle2> tabelle2List= new ArrayList<Tabelle2>();
if (object2List!= null) {
for (Object2 Object2new : object2List) {

Tabelle2 tabelle2 = new Object2new ();


tabelle2.add(tabelle2new );


// add list von tabelle2 to tabelle1

try {
// Update tabelle1

Tabelle1 tabelle1new= entityManager.find(Tabelle1 .class, tabelle1.getNummer());
if (tabelle1new== null) {
// transaction type=JTA : container managed transaction
entityManager.persist(Tabelle1 );

} else {

entityManager.merge(Tabelle1 );

} catch (Exception e) {



} catch (ClassCastException e) {
System.out.println("Class Cast Exception");
} catch (IllegalArgumentException e) {
System.out.println("Illegal Argument Exception");
} catch (Exception e) {
System.out.println("Generic Exception");
Re: entitymanager problem merge [message #1065394 is a reply to message #1064551] Tue, 25 June 2013 14:33 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Ensure you set cascade merge in your mapping.

James : Wiki : Book : Blog : Twitter
Previous Topic:How to access Primary Key instance of entity relationship?
Next Topic:OPEN - Disable delete an entity when is its linked in relationships
Goto Forum:

Current Time: Mon May 21 08:45:14 GMT 2018

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

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

Back to the top