-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Why insertable and updateable as false in hibernate
PostPosted: Tue Aug 12, 2014 3:00 am 
Newbie

Joined: Mon Oct 21, 2013 5:32 pm
Posts: 8
As per Hibernate documentation at http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch05.html, in below example:

Code:
    <class name="Customer">
       <composite-id name="id" class="CustomerId">
          <key-property name="firstName" column="userfirstname_fk"/>
          <key-property name="lastName" column="userfirstname_fk"/>
          <key-property name="customerNumber"/>
       </composite-id>
   
       <property name="preferredCustomer"/>
   
       <many-to-one name="user">
          <column name="userfirstname_fk" updatable="false" insertable="false"/>
          <column name="userlastname_fk" updatable="false" insertable="false"/>
       </many-to-one>
    </class>
   
    <class name="User">
       <composite-id name="id" class="UserId">
          <key-property name="firstName"/>
          <key-property name="lastName"/>
       </composite-id>
   
       <property name="age"/>
    </class>



Quote:
Notice a few things in the previous example:

the order of the properties (and column) matters. It must be the same between the association and the primary key of the associated entity

the many to one uses the same columns as the primary key and thus must be marked as read only (insertable and updatable to false).

unlike with @MapsId, the id value of the associated entity is not transparently copied, check the foreign id generator for more information.


I am new to Hibernate so finding it difficulty in understanding these.

- Why the order of the properties is matters? Which is called as association and which one is associated in first statement?

- Why the columns needs to be set as false for insertable and updateable?

- What is copying transparently? How @MapId makes a difference here?


Can someone please help me in clarifying these.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.