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: Problem with Nhibernate serialization
PostPosted: Wed Aug 27, 2008 11:12 am 
Newbie

Joined: Wed Aug 27, 2008 11:10 am
Posts: 2
Hi all,

now i programm a 3tier project and i use nhibernate to persist data object.



but i get a problem while calling the web servies methode. the exception message looks like this:

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: CProxyTypeHM_ClassLibraryRoomHM_ClassLibrary_NHibernate_ProxyINHibernateProxy1 cannot be serialized because it does not have a parameterless constructor.
at System.Xml.Serialization.TypeDesc.CheckSupported()
at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
at System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(Type type)
at System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(Object o)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write4_Room(String n, String ns, Room o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write18_Room(Object o)
at Microsoft.Xml.Serialization.GeneratedAssembly.RoomSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()

i don't understand the message "cannot be serialized because it does not have a parameterless constructor.
", cause i've already a constructor in my class 'Room'.

using System;
using System.Collections.Generic;
using System.Text;

namespace HM_ClassLibrary
{
[Serializable]
public class Room
{
private int _id;
public virtual int Id
{
get
{
return _id;
}
set
{
_id = value;
}
}

private string _number;
public virtual string Number
{
get
{
return _number;
}
set
{
_number = value;
}
}

private int _hotelId;

public virtual int HotelId
{
get { return _hotelId; }
set { _hotelId = value; }
}

private int _typeId;

public virtual int TypeId
{
get { return _typeId; }
set { _typeId = value; }
}


public Room()
{ }

...


}
}

and there are the mapping code

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HM_ClassLibrary.Room, HM_ClassLibrary" table="Room">

<id name="Id" column="RoomId" type ="System.Int32" >
<generator class="native" />
</id>

<property name="Number" column="RoomNumber" length="3" not-null="true"/>


<many-to-one name="TypeId" column="RoomTypeId" not-null="true" lazy="false"
cascade="all"
unique ="true"
class ="HM_ClassLibrary.RoomType, HM_ClassLibrary"/>

<many-to-one name="HotelId" column= "RoomHotelId" not-null="true" lazy="false"
cascade ="all"
unique ="true"
class ="HM_ClassLibrary.Hotel, HM_ClassLibrary"/>

</class>
</hibernate-mapping>

has anyone any experiences how to resolve those problems.

thx


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.