Hi!
Interesting discussion!
I don't see the solution presented above as a real solution to the problem. I would definitly not be careless when it comes to applying the correct attribute to any of my collections.
It is very clear that you would want to conform to the set contract when you use set attribute on a collection instead of a bag. By using bag just to get the cast to work one is definately beaking the set contract! That is not good!
I believe that jamjam asks for a well established way to create new instances, either touching the real class or an established way to produce an empty hibernate proxy instance, without modifying the attributes to bag, and without having to use any of the Iesi classes.
Then something like this should work:
Code:
ICat cat = SomeFactoryUsingHibernateProxyCreation.Create(typeof(ICat));
cat.AddMate(anotherCatInstance);
dao.save(cat);
Obviously you would not like to write code like that and rather use plain old c# classes:
Code:
ICat cat = new Cat();
cat.AddMate(anotherCatInstance);
dao.save(cat);
Here, the hibernate reflection logic will instead to the conversion from any collection to the attribute defined Iesi collection, without polluting my code.
I hope anyone can give me some clues to stay on the PONO/POCO road I'm currently following or can point to some factory that will produce an empty hibernate proxy based on my interface type or my actual implementation type.
Cheers,
Steinar.[/code]