-->
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.  [ 2 posts ] 
Author Message
 Post subject: Override a property in a subclass
PostPosted: Tue Nov 14, 2006 7:33 am 
Newbie

Joined: Fri Nov 10, 2006 4:42 am
Posts: 6
Hi, I've a problem with table per class hierarchy strategy:

I've a base class NodeACL and the derived classes UserACL, GroupACL.
NodeACL has a property called SecurityObject, which is defined into the other ACL's objects. Infact if you have a UserACL the security object is a User : ISecurityObject and if you have a group the object is a Group : ISecurityObject.

This is my mapping file.... I need to have "SecurityObject" property inside the NodeACL mapping and in all its subclasses... Is it possible?

Thanks!

-----------------------------------------------------------------------------
Mapping file :
-----------------------------------------------------------------------------

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Eureka.Keeper.Security.NodeACL, Eureka.Keeper" table="Keeper_Nodes_ACL">
<id name="Id" access="nosetter.pascalcase-underscore" column="IDACL" type="Int32">
<generator class="identity"/>
</id>
<discriminator column="AllowedType" />
<many-to-one name="Node" access="nosetter.pascalcase-underscore" class="Eureka.Keeper.Node, Eureka.Keeper" column="IDNode" />
<property name="ACLType" access="nosetter.pascalcase-underscore" type="Eureka.Keeper.Security.ACLType, Eureka.Keeper" />

<many-to-one name="SecurityObject" access="nosetter.pascalcase-underscore" class="Eureka.Security.ISecurityObject, Eureka.Core" column="IDAllowed" insert="false" update="false">
</many-to-one>

<subclass name="Eureka.Keeper.Security.UserACL, Eureka.Keeper" discriminator-value="0">
<many-to-one name="SecurityObject" access="nosetter.pascalcase-underscore" class="Eureka.Security.User, Eureka.Core" cascade="none" column="IDAllowed">
</many-to-one>
</subclass>

<subclass name="Eureka.Keeper.Security.GroupACL, Eureka.Keeper" discriminator-value="1">
<many-to-one name="SecurityObject" access="nosetter.pascalcase-underscore" class="Eureka.Security.Group, Eureka.Core" cascade="none" column="IDAllowed">
</many-to-one>
</subclass>

</class>
</hibernate-mapping>

-----------------------------------------------------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 1:00 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
You can't map an interface since NHib can't instantiate an interface, unless you want it to create a proxy.
You could have an abstract class all your ISecurityObject implementors inherit from and have that class mapped (hbm.xml) with discriminators for the different types. Nhibernate would load the appropriate type for each of your ACL classes' properties (SecurityObject) because they have their own discriminators.

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.