-->
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: About composite-id query???
PostPosted: Thu Apr 20, 2006 10:47 pm 
Newbie

Joined: Thu Apr 13, 2006 1:56 am
Posts: 11
Hibernate version:1.0.2

Mapping documents:
test (1)---------->subtest (N)
test.hbm.xml:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Entity.Test,Entity" table="Test" lazy="true">
<composite-id>
<key-property name="keyOne" column="keyOne" type="Int32" />
<key-property name="keyTwo" column="keyTwo" type="Int32" />
</composite-id>
<property name="myproperty" column="myproperty" type="String"/>
<property name="myint" column="myint" type="Int32"/>

<bag name="SubTestList" cascade="save-update" inverse="true" lazy="true">
<key>
<column name="keyOne"/>
<column name="keyTwo"/>
</key>
<one-to-many class="Entity.SubTest,Entity"/>
</bag>
</class>
</hibernate-mapping>

subtest.hbm.xml:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Entity.SubTest,Entity" table="SubTest" lazy="true">
<composite-id>
<key-property name="keyOne" column="keyOne" type="Int32" />
<key-property name="keyTwo" column="keyTwo" type="Int32" />
<key-property name="keyThree" column="keyThree" type="Int32" />
</composite-id>

<property name="mySubproperty" column="myproperty" type="String"/>

<many-to-one name="Parent" class="Entity.Test,Entity" insert="false" update="false">
<column name="keyOne"/>
<column name="keyTwo"/>
</many-to-one>
</class>
</hibernate-mapping>

Class: (ignore),
and already override Equals() and GetHashCode().

test code:
public void test()
{
// already add data:
//test(1,1"test",15)
//subtest(1,1,1,"sub1")
//subtest(1,1,2,"sub2")
SubTest sub = session.Get(typeof(SubTest), new SubTest(1, 1, 1)) as SubTest;

Assert.IsNotNull(sub .Parent);
Assert.IsTrue(sub .Parent.myint == 15);
}


run test throw exception:

test: NHibernate.HibernateException : Creating a proxy instance failed
----> System.MissingMethodException : Constructor on type 'CProxyTypeTestSystem_INHibernateProxy_ISerializable2' not found.

why? I don't know this exception,
please,help me,thank you


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.