• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Hibernate Bi Directional Problem

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I am facing a problem in hibernate bidirectional. I have 2 classes TOrder and LineItem.

What is the problem in the xml file. Is this correct? Or do i need to create the seperate xml file ?

for Bi directional i created the Ora.hbm.xml as

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="com.bo.TOrder" table="T_ORDER">
<id name ="orderID" type="int">
<column name="ORDERID" not-null="true"/>
<generator class="hilo"/>
</id>
<property column="userName" name="userName" />
<property column="total" name="total" />
<set name="lineItem" inverse="true" lazy="true" cascade="all">
<key column="orderID"/>
<one-to-many class="com.bo.LineItem"/>
</set>
</class>

<class name="com.hibernate.example.bo.LineItem" table="T_LINEITEM">
<id type="int">
<column name="ID" not-null="true"/>
<generator class="hilo"/>
</id>
<property column="itemName" name="itemName" />
<property column="unitPrice" name="unitPrice" />
<property column="discount" name="discount" />
<many-to-one name="order" class="com.bo.TOrder" column="orderID"/>
</class>
</hibernate-mapping>


Thanks in Advance
Anna Madhusudhanan
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The <key/> element in the <set/> should name the column in the "other" table that holds a reference to "this" table's ID.

I.e. something like:
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, wait. That's exactly how you had it. Hmm.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anna Madhusudhanan Natanagopalan:
I am facing a problem in hibernate bidirectional. I have 2 classes TOrder and LineItem.

Would you care to share it with us? What exactly is the problem? Does Hibernate give you an error when reading the mapping files? Do you get a runtime error when loading objects?
 
Anna Madhusudhanan Natanagopalan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting error at run time.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a stack trace to give us? Otherwise it's rather difficult to get an idea of what's happening.
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic