Announcement Announcement Module
Collapse
No announcement yet.
one-to-one mapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • one-to-one mapping

    Hello All,

    one-to-one mapping not working

    Code:
    <hibernate-mapping>
        <class name="com.example.A" table="TAB_A">
        	<id name="id" type="java.lang.Long">
                <column name="ID" />
            </id>
            <one-to-one name="item" class="com.example.LineItem" />
        </class>
    </hibernate-mapping>
    
    Class A
    =========
    
    public class A  implements java.io.Serializable
    {
    	Long id;
    	LineIten item
    	
    	...<getter setter>
    }
    
    public class LiteItem  implements java.io.Serializable
    {
    	Long id;
    	....
    	
    	...<getter setter>
    }
    I am calling save from Spring layer using getHibernateTemplate().saveOrUpdate( a ); This throws exception
    java.sql.BatchUpdateException: ORA-01400: cannot insert NULL

    I saw the insert and I noticed that it is not including item (item_id) in the insert statement generated.

    Any idea whats going wrong here.

    springnewbie

  • #2
    pk in TAB_A is with column ID

    and in LineItem its with column name ID.

    Will this be an issue?

    property reference in class can be different than column key and I guess that should not be the problem. Please let me know if that is wrong
    Last edited by springnewbie; Dec 29th, 2008, 11:05 PM.

    Comment

    Working...
    X