-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to Copy Object Graph and Lazy Collection for...
PostPosted: Sun Feb 04, 2007 4:52 pm 
Newbie

Joined: Thu Jan 19, 2006 7:24 am
Posts: 17
How to copy Object Graph, and Lazy Collection for each Objects inside Object Graph?


Now.. I'm using Session.Connection To get ADO.NET Connection Object then Executes sql selection-insertion command.


Dose Nhibernate provide some solusions?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 1:50 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
I have found a nice solution in the internet which mets our requirements. We clone our object graphs by serialization. The code in our BaseModel class is the following:

Code:
/// <summary>
/// Clones the object by using serialization and deserialization.
/// </summary>
/// <returns>
/// A deep copy of the object.
/// </returns>
private object cloneBySerialization()
{
  Object result;
  MemoryStream buffer = new MemoryStream();
  BinaryFormatter formatter = new BinaryFormatter();
  formatter.Serialize(buffer, this);
  buffer.Position = 0;
  result = formatter.Deserialize(buffer);
  return result;
}


As we don't use lazy collections (because of the specific requirements in our application) this works fine for us.

Regards
Klaus


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 2:49 am 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
I am interested to see how good/bad is the performance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 1:10 pm 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
we haven't measured the performance because we didn't see a noticable slowdown of our application. We clone a very complex object tree with three level deep nested collections and around 50 to 100 object instances via this method. But we only do it on user request for a single object tree.

Regards
Klaus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 10:02 pm 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
Thanks Klaus


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.