-->
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.  [ 3 posts ] 
Author Message
 Post subject: HELP!!! BEGINNER QUESTION!!!! HELP!!!
PostPosted: Fri Sep 09, 2005 2:17 pm 
Newbie

Joined: Fri Sep 09, 2005 11:11 am
Posts: 19
public class Order
{
private String orderId;
private String detail;
private Item item;
}

public class Item
{
private String itemId;
private String itemName;
}

===============

Each class maps to a different database table.

session.save(order) would saves orderId and detail into the order table but information in item property would be saved into item table.

order = session.load(Order.class, "123"); would load orderId amd detail from order table but it loads data from the item table into the property item.

Would anyone show me how to write the mapping file?
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 5:15 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
Would this work for you?

Mapping for Order:
Code:
<hibernate-mapping>
    <class entity-name="Order">
        <id name="orderId" type="String" column="ORDER_ID"/>
        <property name="detail" column="DETAIL" type="string"/>
        <many-to-one name="item" column="ITEM_ID" class="Item"/>
</hibernate-mapping>


Mapping for Item:
Code:
<hibernate-mapping>
    <class entity-name="Item">
        <id name="ItemId" type="String" column="ITEM_ID"/>
        <property name="itemName" column="ITEM_NAME" type="string"/>
</hibernate-mapping>


You may want to refer: http://www.hibernate.org/hib_docs/v3/re ... ml_single/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 5:20 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
Small change. You may want to replace the
Code:
<many-to-one name="item" column="ITEM_ID" class="Item"/>
with
Code:
<one-to-one name="item" column="ITEM_ID" class="Item"/>


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