-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Merge transient object with childrens
PostPosted: Thu Nov 25, 2010 6:15 pm 
Newbie

Joined: Thu Nov 25, 2010 5:48 pm
Posts: 1
Hello,


I've some probleme with merge. My update method works in this way:

Code:
void update(Parent parent) {
    evict(parent);
    merge(parent);
}


My classes:

Code:
Parent {

  Long id;

  List<Children> childrens;

  @OneToMany(targetEntity =ChildrenImpl.class, fetch=FetchType.LAZY)
  @JoinColumn(name="PARENT")
  @org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.ALL)
  List<Children> getChildrens(){...}

  @Id
  Long getId() {...}

}



Code:
Children{

  Parent parent;

  @ManyToOne(targetEntity = ParentImpl.class, fetch = FetchType.LAZY)
  @org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.ALL)
  @JoinColumn(name = "PARENT", nullable = false)
  Parent getParent(){...}

}


When i create a new Parent object and add new childrens and trying updated(evict & merge) then logs show me this after flush hibernate session:

Code:
INSERT PARENT //everythings here is ok.

INSERT CHILDREN // but without parent id(id=null)


Order is good but children doesn't have parent id in insert. Everything works fine when Parent is persisted in database, then childrens always have a good id.

Any ideas what should I do to get id from transient object(from persisted is ok).

Regards
KZ.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.