• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem while One to One Relationship

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
reply
    Bookmark Topic Watch Topic
  • New Topic