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: Problem with XMLserialization persistent NH1.2alpha objects
PostPosted: Wed Aug 09, 2006 10:18 am 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
While trying to serialize (usual .NET serialization to XML) object retrieved
via. NHibernate query got exception.
"There was an error generating the XML document."

The research showed that exception appeared
for domain objects agents which are reffered by other
domain objects in the same NHibernate session.

IList<Agent> agents = agentsSerializer.GetAgents(new AgentsFilter());
XmlSerializer serializer = new XmlSerializer(typeof(Agent));

foreach (Agent agent in agents)
{
TextWriter writer = new StreamWriter(@"c:\src\test.xml");
serializer.Serialize(writer, agent);
writer.Close();
}

So serializer.Serialize(..) fails only for
agents which are child entities
<many-to-one name="Agent" class="Agent" column="AgentID"/>
of other domain objects in the same session.

In Visual Studio debugger I see
that such agents implements some NHibernate interface
CProxyTypeAgentDomain_INHibernateProxy_ISerializable2

Could you please give me some advise or workaround?

Thanks!


Top
 Profile  
 
 Post subject: lazy="true" for Agent class helped but question re
PostPosted: Wed Aug 09, 2006 10:26 am 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
sergunok wrote:
While trying to serialize (usual .NET serialization to XML) object retrieved
via. NHibernate query got exception.
"There was an error generating the XML document."

The research showed that exception appeared
for domain objects agents which are reffered by other
domain objects in the same NHibernate session.

IList<Agent> agents = agentsSerializer.GetAgents(new AgentsFilter());
XmlSerializer serializer = new XmlSerializer(typeof(Agent));

foreach (Agent agent in agents)
{
TextWriter writer = new StreamWriter(@"c:\src\test.xml");
serializer.Serialize(writer, agent);
writer.Close();
}

So serializer.Serialize(..) fails only for
agents which are child entities
<many-to-one name="Agent" class="Agent" column="AgentID"/>
of other domain objects in the same session.

In Visual Studio debugger I see
that such agents implements some NHibernate interface
CProxyTypeAgentDomain_INHibernateProxy_ISerializable2

Could you please give me some advise or workaround?

Thanks!


Top
 Profile  
 
 Post subject: Still very interested in solving this bug / issue!
PostPosted: Sat Aug 12, 2006 1:49 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
*


Top
 Profile  
 
 Post subject: Circular Reference
PostPosted: Tue Aug 22, 2006 1:02 am 
Newbie

Joined: Wed Aug 17, 2005 6:25 am
Posts: 4
Is the error you are getting say anything about circular reference. if so decorate the parent property of the child classes with [xmlignore] alternatively u can set the parent property to null


Top
 Profile  
 
 Post subject: There are no circular references in my classes
PostPosted: Tue Aug 22, 2006 4:54 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
And I'm still interested in solving this problem :(((


mahlombe wrote:
Is the error you are getting say anything about circular reference. if so decorate the parent property of the child classes with [xmlignore] alternatively u can set the parent property to null


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.