Please explain about: insertable=false, updatable=false?

You would do that when the responsibility of creating/udpating the related entity in question isn't in the current entity. E.g. You have a Person and an Address You'd like to add insertable=false, updatable=false to the OneToMany relationship with the Person entity in the Address entity, simply because it's not the responsibility of the Address entity to create or update a Person It's the other way round.

This is not really a technical, but more a semantic/natural decision.

You would do that when the responsibility of creating/udpating the related entity in question isn't in the current entity. E.g. You have a Person and an Address.

You'd like to add insertable=false, updatable=false to the @OneToMany relationship with the Person entity in the Address entity, simply because it's not the responsibility of the Address entity to create or update a Person. It's the other way round. This is not really a technical, but more a semantic/natural decision.

Sorry I was still writing code, but it is updated now :D – Harry Pham Sep 27 '10 at 17:06 More than one Person can live in one Address. I usually put those constraints in the annotation representing the relationship, not the column. But I think you got the point :) By the way if you don't define them, then JPA may complain with "multiple writable mappings exist for the field" error during initialization.

– BalusC Sep 27 '10 at 18:21 What if you don't define them. Is them refer to the relationship between Person and Address? – Harry Pham Sep 27 '10 at 18:43 It refers to defining insertable=false,updatable=false on one of the sides of the relationship.

– BalusC Sep 27 '10 at 18:47 1 @Harry if you don't define them, then JPA may complain with "multiple writable mappings exist for the field" error during initialization JPA would only complain if you map some field more than once in an entity, it won't complain with a simple bidirectional association. Using insertable, updatable is absolutely not necessary in such case. – Pascal Thivent Sep 27 '10 at 23:26.

Defining insertable=false, updatable=false is useful when you need to map a field more than once in an entity, typically: when using a composite key when using a shared primary key when using cascaded primary keys This is IMO not a semantical thing, but definitely a technical one.

Thank you. Will ask more question, once I done the reading. Thank you :D +1 – Harry Pham Sep 27 '10 at 20:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions