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.
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); }
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.