-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with a One to many Mapping
PostPosted: Thu Jan 12, 2006 9:53 am 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
Hi. I am very new to nHibernate so forgive me if this Question is Foolish. I am Trying to Create a One to many mapping I am getting a Run time error. INVALIDCASTEXCEPTON

The Basic ideas is an Account can have Many Transactions.....

1)Account File:-
Mapping Files:-


<id name="ACCOUNT_NUMBER" column="ACCOUNT_NUMBER" type="System.String">
<generator class="assigned"/>
</id>

......

<bag name="Transaction" table = "Trans_History">
<key column="TRANS_ID"/>
<one-to-many class="Prasanth.TRANS_HISTORYEntity, Prasanth"/> </bag>

Class File:-

[Serializable]
public class ACCOUNT_DETAILSEntity
{
private string _ACCOUNT_NUMBER;
private IList Transaction; // To store Transactions.
}



2nd) Transaction File:-

Mapping File:-

<id name="TRANS_ID" column="TRANS_ID" type="System.Double">
<generator class="assigned"/>
</id>

<many-to-one name="ACCOUNT_NUMBER" column="ACCOUNT_NUMBER" class="Prasanth.ACCOUNT_DETAILSEntity, Prasanth"/>

The Respictive Class File:

private string Trans_id;
private IDictionary Account_Number;


Now this Throws an Error. Can Anyone help me out with this..

Thanking You


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 10:02 am 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
Also in the above Question My Transaction List of Account is Empty. How do i see that That List Get All the Transactions or A selected Few Transactions in the List.


Thanks


Top
 Profile  
 
 Post subject: Question
PostPosted: Thu Jan 12, 2006 11:27 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
why is your Account_Number member variable in class Prasanth.TRANS_HISTORYEntity declared as IDictionary. I think it should be Prasanth.ACCOUNT_DETAILSEntity because it is referring to the ONE side of the MANY-ONE relationship, so it should refer to some entity not IDictionary


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 11:56 pm 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
Hey samujob,

Thankz That Worked.

Now i have 2 More Qurstions:
1) How do i see that the Transaction List Get all the Values of the respictive Account. ie: My Account Class has an IList of Transactions. How does that get Populted.

2)Not very Important. But when do we use a IDictionary??


Thankz......


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