-->
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: Hibernate nested obeject- help needed
PostPosted: Fri Jan 25, 2013 2:42 pm 
Newbie

Joined: Fri Jan 25, 2013 2:40 pm
Posts: 1
I am much new to hibernate and i am stuck at a point.
I am trying to save nested object and out of those nested objects i dont want to save one object. How can i achive this?
When i am running this i am getting transient exception "org.hibernate.TransientObjectException: object references an unsaved transient instance". I know i am doing something stupid whihc is not recommended by hibernate. Please help.



Scenario:
A, B, C, D are four diffrent tables.

Table A ( field1, field2 , field3[fk to table B])
Table B ( field3, field4 , field5 [fk to table C])
Table C ( field5, field7 , field8)
Table D ( field6, field9 , field3[fk to table B])


Objects

A
private String field1;
private String field2;
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="field3")
private B b;


B
private String field3;
private String field4;
/*Want to save D*/
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="field3")
private List<D> d; // This is a list of D
/*Dont want to save C*/
@OneToOne
@JoinColumn(name="field5")
private C c;

C
private String field5;
private String field7;
private String field8;
D
private String field6;
private String field9;
private String field3;

Thanks
Ashish


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.