-->
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: Windows Communication Foundation (May CTP) and NHib Bag
PostPosted: Fri Jun 23, 2006 5:01 pm 
Newbie

Joined: Thu Nov 17, 2005 1:03 pm
Posts: 9
Location: Round Rock, TX
Hibernate version:1.0.2

My Context
I use WCF to send NHibernate Bags over the wire, which means the collection is serialized/deserialized by the DataContractSerializer (from the System.Runtime.Serialization namespace in the May CTP of WinFx)
Now I already know that this breaks at least one of the 4 tenants of SOA, but in my scenario it's the simplest thing that works, well, it used to work in the Feb CTP....

My Issue
Now if you try this in the latest WCF bits you'll get the following exception message:

Type 'NHibernate.Collection.PersistentCollection' is an invalid collection type since it does not have a valid Add method with parameter of type 'System.Object'

(I've posted the original problem at http://forums.microsoft.com/MSDN/ShowPo ... 9&SiteID=1)

I've recently discovered that the May bits of the DataContractSerializer (and probably the RTM bits as well) require collection types that implement ICollection or IEnumerator to contain an Add method that takes a System.Object as a parameter and also requires it to have a default constructor (they can both be private).

My Solution
So, to resolve this I had to modify the source of the Nhibernate.Collection.PersistentCollection to have the private Add method and I had to modify the Nhibernate.Collection.Bag to have a default constructor.

I haven’t tried it but I assume that the 1.2.0 PersistentBag would also need a default constructor if it were to be used to hold data for a WCF message.

My Recommendation
It sure would be nice if the 1.2.0 version the collections were made to be WCF friendly by having at a minimum default private constructor and private a Add method. Now, there may be a million reasons why this is a terrible idea that I haven’t considered, but I just thought I'd throw this idea out there...

Greg Banister


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.