-->
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.  [ 2 posts ] 
Author Message
 Post subject: exporting data from file to db
PostPosted: Tue Jul 13, 2004 4:54 pm 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
hi, all
I use xstream for serializing the objects that I load from database (mapped by hibernate) to a xml file. It works fine but when I try to load that object to db , I got some db exceptions like unique key violation or first insert the object b...
That is because of the many-to-one association.

(lets say A and B has many to one relation)

serializefile(session.find("Select from A").get(0), serializedfile);
// A is saved to file with associated attr B.

A a = deserializeFrom(serializedfile);
// the previously serialized A object is constructed from file

a.setName("namechanged");
// some attr. of a changed

session.saveOrUpdate(a);
// Error; here it gives "first insert the obj B..." error. But B is already in the database since it was loaded from there.

I load the associated B with A to the file and I reload that B with A to the db, but it says no such B in the db?
Why can this be occur?
* I do not map all of attributes of B,
Db manager should consider the same B's as 2 different object even if their id and all mapped attr. are equal???
* Can I put a some helpful info for the mapping file that helps db manager to understand that these 2 objects are equal?

<class A ....
...
...
<many-to-one name= "b" class= "B" column="bid" ..........

To sum up, how can easily manage saving and loading associations?

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 4:16 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
ignore this! -))

_________________
-developer


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

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.