Setting a relationship's update and insert attributes

Is it possible to set the update=“false” insert=“false” attribute of a relationship using DBVA?

Basically I want a generated relationship to have update=“false” insert=“false” as follows:

<many-to-one name=“school” cascade=“lock” column=“domainid” update=“false” insert=“false” class=“com.test.db.Rc_school” not-null=“true” lazy=“no-proxy” access=“field”>

Is it possible to do this from DBVA?

Hi Jvence,

Thanks for your post. After you synchronized the Entity Relationship Diagram (ERD) to class diagram, you can open Specification dialog of the association, switch to ORM Association Detail tab to check Read only (as attached image). Then you will get update=“false” insert=“false” generated in the mapping file. If there is any further inquiry, please feel free to contact me.

Best regards,
Lilian Wong

specify_read_only.png

The problem with selecting the “read only” checkbox is that DBVA does not generate any setter function (which a user might manually use to create an association between the two objects.

Hi Jvence,

Thanks for replying. In this case, you need to have Primary Key which is also a Foreign Key, then select “key-property” for Composite ID with Association in Advanced Settings when generate code (please see attached image). Then you can generate update=“false” insert=“false” in the mapping file.

Please feel free to ask if you have any further question.

Best regards,
Lilian Wong

select_key_property.png

I did the same and I got update=“false” insert=“false” in the mapping file. Also the hbm of parent table is having 'inverse=“false”.

However, I am getting this error while creating session factory.
Parent table hbm

	<list name="CxPayCodeValue" lazy="false" cascade="save-update,lock" inverse="false">
		<key column="LISTCODE" not-null="true"/>
		<index column="SORT_ORDER" type="long"/>
		<one-to-many class="com.chordiant.cxpay.offer.businessobject.internal.CxPayCodeValue"/>
	</list>

Child table hbm:

	<composite-id>
		<key-property name="code" column="CODE" type="string"/>
		<key-property name="cxPayCodeList_CODE" column="LISTCODE" type="string"/>
	</composite-id>
	<many-to-one name="cxPayCodeList" column="LISTCODE" class="com.chordiant.cxpay.offer.businessobject.internal.CxPayCodeList" insert="false" update="false">
	</many-to-one>

Error :

Error creating bean with name ‘cxpay-offerSessionFactory’ defined in class path resource [config/cxpay-offerDaoContextTest.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.chordiant.cxpay.offer.businessobject.internal.CxPayCodeValue column: LISTCODE (should be mapped with insert=“false” update=“false”)

Could you please tell me why ?

Would you mind send me your project file to have a look? You can send to rain@visual-paradigm.com. Look forward to hear from you.

Best regards,
Rain Wong