-->
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: Generics Problem
PostPosted: Fri May 05, 2006 12:07 pm 
Regular
Regular

Joined: Fri May 05, 2006 11:54 am
Posts: 51
Hi all,

I am having problems with the Generics feature of the following

http://www.ayende.com/projects/nhibernate-query-analyzer/generics.aspx

My problem concerns specifically a many to many problem but may also affect one to many. I have a class called FileAsset which has a relationship with a collection of parameters. I have defined this relationship as follows:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="orange.core.domain.Asset, orange.core" table="Asset" proxy="orange.core.domain.Asset, orange.core" discriminator-value="0">
<cache usage="read-write"/>
<id name="Id" column="Id" type="Int32" unsaved-value="-1">
<generator class="native">
<param name="sequence">orange_assetid_seq</param>
</generator>
</id>
<discriminator column="AssetType" type="Int32"/>
<property name="Name" column="Name" type="String" length="250"/>
<property name="Display" column="Display" type="Boolean"/>
<property name="InsertTimestamp" column="inserttimestamp" type="DateTime"/>
<bag name="AssetItems" cascade="all">
<!--inverse="true" lazy="true" order-by="Id">-->
<cache usage="read-write"/>
<key column="AssetId"/>
<one-to-many class="orange.core.domain.AssetItem, orange.core"/>
</bag>
<subclass name="orange.core.domain.ImageAsset, orange.core" discriminator-value="1" proxy="orange.core.domain.ImageAsset, orange.core"/>
<subclass name="orange.core.domain.FlashAsset, orange.core" discriminator-value="2" proxy="orange.core.domain.FlashAsset, orange.core">
<bag name="InternalParameters" cascade="all" table="AssetParameter" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics">
<cache usage="read-write" />
<key column="AssetId" />
<many-to-many class="orange.core.domain.Parameter, orange.core" column="ParameterId" outer-join="true"/>
</bag>
</subclass>
</class>
</hibernate-mapping>

Here is the parameter class:

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="orange.core.domain.Parameter, orange.core" table="Parameter" proxy="orange.core.domain.Parameter, orange.core">
<cache usage="read-write"/>
<id name="Id" column="Id" type="Int32" unsaved-value="-1">
<generator class="native">
<param name="sequence">parameter_assetid_seq</param>
</generator>
</id>
<timestamp name="UpdateTimestamp" column="updatetimestamp" />
<property name="Name" column="Name" type="String" length="100" />
<property name="ParameterValue" column="ParameterValue" type="String" length="100" />
</class>
</hibernate-mapping>


The article seems to imply that this relationship needs to be maintained on both sides. I don’t want the parameter objects to know anything about their parents because they could be different types.

The sample uses the constructors like so:

_blogs = new EntitySet<Blog>(
delegate(Blog b) { b.Users.Add(this); },
delegate(Blog b) { b.Users.Remove(this); },
InitializeOnLazy.Always);

I don’t want the Parameter object to have a reference to the FileAsset.

Is this possible using the Generics feature??

Could anyone send me any sample code if they have any??

Thanks


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.