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: Columns in Subclass Hierarchy have same names not working
PostPosted: Wed Aug 29, 2007 9:15 am 
Newbie

Joined: Wed Aug 29, 2007 9:03 am
Posts: 2
Hi there,

I have the following mapping file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="CQPA.Operations.Storage" assembly="CQPA.Operations.Storage" >

<class name="PropertyBase" table="EquipmentProperties" discriminator-value="???">

<id name="Id" column="ID" type="System.Guid">
<generator class="guid" />
</id>

<discriminator column="PropertyType" type="string" length="3" />

<property name="Name" column="Name" type="string" length="128"/>
<property name="Description" column="Description" type="string" length="256"/>
<property name="DataType" column="DataType" type="System.Type"/>
<property name="UnitOfMeasure" column="UnitOfMeasure" type="string" length="32"/>
<property name="QualifiedName" formula="EquipmentID + '.' + Name" access="field.camelcase-underscore" type="string"/>

<subclass name="ClassPropertyTemplate" discriminator-value="CPT">
<many-to-one name="EquipmentClass" column="EquipmentClassID" class="EquipmentClass" lazy="false"/>
<property name="Tag" column="Tag" type="string" length="256"/>
<many-to-one name="QueryTemplate" column="QueryTemplateID" class="QueryTemplate" lazy="false"/>
</subclass>

<subclass name="EquipmentProperty" discriminator-value="EP?">

<many-to-one name="Equipment" column="EquipmentID" class="Equipment" lazy="false"/>

<subclass name="EquipmentPropertyConstant" discriminator-value="EPC">
<property name="Constant" type="string" length="256"/>
</subclass>

<subclass name="EquipmentPropertyQuery" discriminator-value="EPQ">
<property name="Tag" type="string" length="256"/>
<many-to-one name="QueryTemplate" column="QueryTemplateID" class="QueryTemplate" lazy="false"/>

<subclass name="EquipmentClassPropertyQuery" discriminator-value="ECP">
<many-to-one name="EquipmentClass" column="EquipmentClassID" class="EquipmentClass" lazy="false"/>
</subclass>

</subclass>

</subclass>
</class>

</hibernate-mapping>

I'm reusing the columns for "Equipment", "Tag" & "EquipmentClass" in some of my subclasses, but not all. If I try to do this it doesn't work. If I rename the columns to be unique they work fine, but this doesn't look good and my client will likely want me to throw NHibernate out because of it.

Can anyone help me please? How do I make this work?

Cheers.

James.


Top
 Profile  
 
 Post subject: column="Tag"
PostPosted: Wed Aug 29, 2007 8:23 pm 
Newbie

Joined: Wed Aug 29, 2007 9:03 am
Posts: 2
I think I solved it.

I had the two following definitions in my mapping file:

<property name="Tag" column="Tag" type="string" length="4096"/>
...
<property name="Tag" type="string" length="4096"/>

The second mapping omitted the 'column="Tag"' attribute. I put that in and it worked fine.

Nasty little oversight. Surely NHibernate should report an error or warning on this kind of situation?

Thanks, nevertheless.

James.


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.