This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Problem while One to One Relationship  RSS feed

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem while performing One to One RelationShip as shown below.

If there are four rows in shipment table the last row cannot get order name
i.e s.getOrderPOJO().getOrderName() throws Exception for last row.
I am not able to understand why.

Thanks
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using one-to-one bidirectional mapping right? you are passing shipment object in order object but not the order object in shipment. I am not sure whether this will work or not.

public void orderShipment(){
Shipment s=new Shipment();
s.setCity("Mumbai");
s.setZipCode("1");
Order o=new Order();
o.setOrderName("S/W Order");
o.setShipment(s);
s.setOrderName(o); ////////Line this can be one issue.
em.persist(o);
}

Regards,
Nitin
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gowher.
I've test your code whithout problems... making an hbm2ddl auto.
I've run the client several times and received correct Order.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pedro Erencia

Can you tell me which application server and IDE you are using.
What is hbm2ddl?

Thanks
 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
eclipse 3.3 and JBoss 4.2.2
hbm2ddl is a property you can place in your persistence.xml to create the database tables automatically from the entity beans.

<property name="hibernate.hbm2ddl.auto">create</property>
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Netbeans5.5 and Sun application server 9.0

Inside persistence.xml
----------------------
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!