Click here to Skip to main content
15,909,953 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL challenge Pin
Colin Angus Mackay31-Mar-05 4:18
Colin Angus Mackay31-Mar-05 4:18 
GeneralRe: SQL challenge Pin
Chris Losinger31-Mar-05 5:15
professionalChris Losinger31-Mar-05 5:15 
Questionparameterized queries? Pin
IlanTal31-Mar-05 3:31
IlanTal31-Mar-05 3:31 
AnswerRe: parameterized queries? Pin
IlanTal31-Mar-05 18:38
IlanTal31-Mar-05 18:38 
GeneralReading BLOB data from database Pin
Member 165844231-Mar-05 1:37
Member 165844231-Mar-05 1:37 
GeneralRe: Reading BLOB data from database Pin
Member 165844211-Apr-05 2:57
Member 165844211-Apr-05 2:57 
QuestionReporting Service - bug with drilldown? Pin
devvvy30-Mar-05 23:56
devvvy30-Mar-05 23:56 
GeneralNHibernate Child-Parent relationship -- Key happens to be a composite key Pin
devvvy29-Mar-05 23:23
devvvy29-Mar-05 23:23 
Help! Child-Parent relationship -- Key happens to be a composite key

Hi, I'm having a lot of trouble trying to get this work. I have two classes:
1. AppProperty (Parent)
2. AppPropertyValue (Child)

1. AppProperty class' PK column is PropertyUIN (Int32).
2. AppPropertyValue class' composite key column is {PropertyUIN (Int32), PropertyValue (String)}
3. One AppProperty instance can relate to MANY AppPropertyValue instance. The two are related by "PropertyUIN".

Trouble is, when I tried to persist the child class, I get:

SqlException wrapped around by a NHibernate.ADOException

Message "Column name 'PropertyUIN' appears more than once in the result column list.
Statement(s) could not be prepared." String

"PropertyUIN" appears twice because it's part of the composite key AND at the same time it appears for the second time in AppPropertyValue's hbm file for I need to declare "many-to-one" between AppProperty and AppPropertyValue. What should I do to resolve this situation?

Thanks in advance.


Code Fragment:

Public Class AppProperty
Implements ISerializable

Protected _propertyUIN As Int32
...
...
Public Property PropertyUIN() As Int32
Get
Return _propertyUIN
End Get
Set(ByVal Value As Int32)
_propertyUIN = Value
End Set
End Property
...
End Class

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="application.utilities.settings.AppProperty, Utility" table="AppProperty">
<id name="PropertyUIN" column="PropertyUIN" type="Int32" >
<generator class="identity" />
</id>
... stuff ...
<set name="Values" inverse="true" cascade="all" table="AppPropertyValue">
<key column="PropertyUIN"/>
<one-to-many class="application.utilities.settings.AppPropertyValue, Utility"/>
</set>
... the rest of it ...
</class>
</hibernate-mapping>


Public Class AppPropertyValue
Implements ISerializable

Protected _propertyUIN As Int32
Protected _propertyValue As String

Protected _parentProperty As AppProperty
...
...
Public Property PropertyUIN() As Int32
Get
Return _propertyUIN
End Get
Set(ByVal Value As Int32)
_propertyUIN = Value
End Set
End Property

Public Property PropertyValue() As String
Get
Return _propertyValue
End Get
Set(ByVal Value As String)
_propertyValue = Value
End Set
End Property

Public Property ParentProperty() As AppProperty
Get
Return _parentProperty
End Get
Set(ByVal Value As AppProperty)
_parentProperty = Value
End Set
End Property
...
End Class

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="application.utilities.settings.AppPropertyValue, Utility" table="AppPropertyValue">
<composite-id>
<key-property name="PropertyUIN" column="PropertyUIN" type="Int32"/>
<key-property name="PropertyValue" column= "PropertyValue" type="String" length="2500"/>
</composite-id>
<many-to-one name="ParentProperty" column="PropertyUIN" class="application.utilities.settings.AppProperty, Utility" />
... stuff ...
</class>
</hibernate-mapping>

CREATE TABLE AppProperty (
PropertyUIN INTEGER IDENTITY(1,1),
...
PRIMARY KEY (PropertyUIN)
)

CREATE TABLE AppPropertyValue (
PropertyUIN INTEGER,
PropertyValue VARCHAR(2500),
...
)
GeneralPackage and deployment Pin
Salman Sheikh29-Mar-05 19:00
Salman Sheikh29-Mar-05 19:00 
GeneralLaunching SQL Server job xp_cmdshell Pin
devvvy29-Mar-05 17:32
devvvy29-Mar-05 17:32 
GeneralOracleClient and Timestamp datatype Pin
Yos Nugroho29-Mar-05 17:21
Yos Nugroho29-Mar-05 17:21 
GeneralGUIDs as PK's Pin
Marc Clifton29-Mar-05 10:04
mvaMarc Clifton29-Mar-05 10:04 
GeneralRe: GUIDs as PK's Pin
rwestgraham29-Mar-05 10:25
rwestgraham29-Mar-05 10:25 
GeneralRe: GUIDs as PK's Pin
Carl Mercier1-Apr-05 10:24
Carl Mercier1-Apr-05 10:24 
GeneralRe: GUIDs as PK's Pin
Marc Clifton4-Apr-05 5:16
mvaMarc Clifton4-Apr-05 5:16 
GeneralRe: GUIDs as PK's Pin
Andy Brummer29-Mar-05 11:14
sitebuilderAndy Brummer29-Mar-05 11:14 
GeneralRe: GUIDs as PK's Pin
turbochimp29-Mar-05 19:19
turbochimp29-Mar-05 19:19 
GeneralRe: GUIDs as PK's Pin
Scott Serl30-Mar-05 13:58
Scott Serl30-Mar-05 13:58 
GeneralRe: GUIDs as PK's Pin
Michael P Butler31-Mar-05 6:24
Michael P Butler31-Mar-05 6:24 
GeneralRe: GUIDs as PK's Pin
Michael Potter1-Apr-05 4:56
Michael Potter1-Apr-05 4:56 
GeneralRe: GUIDs as PK's Pin
Carl Mercier1-Apr-05 10:27
Carl Mercier1-Apr-05 10:27 
Questionhow to find server name of oracle Pin
satishrg29-Mar-05 8:55
satishrg29-Mar-05 8:55 
AnswerRe: how to find server name of oracle Pin
Colin Angus Mackay29-Mar-05 11:00
Colin Angus Mackay29-Mar-05 11:00 
AnswerRe: how to find server name of oracle Pin
Andy Brummer29-Mar-05 11:30
sitebuilderAndy Brummer29-Mar-05 11:30 
GeneralPermissions Pin
vuthaianh28-Mar-05 17:50
vuthaianh28-Mar-05 17:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.