Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem while One to One Relationship

 
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>
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic