Hi everyone,
Just like the subject says, I'm working out in a java persistence migration, from Oracle Toplink to Hibernate and we have found a problem. First at all, we aren't working with JPA, so, all it will mapped with hbm.xml. This is a little part of the data model.
And this is a little part of the Diagram Class.
The original mapping on toplink has this descriptor for CustomerVoucherAgreementImpl.
Code:
<descriptor>
<java-class>com.corepass.model.agreement.CustomerVoucherAgreementImpl</java-class>
[b]<tables>
<table>E_AGREEMENT</table>
<table>E_CUSTOMER_AGREEMENT</table>
<table>E_VOUCHER_CUST_AGREEMENT</table>
<table>E_VOUCHER_CUST_AGREEMENT_CL</table>
</tables>[/b]
<primary-key-fields>
<field>E_AGREEMENT.AGREEMENT_ID</field>
</primary-key-fields>
<descriptor-type-value>Normal</descriptor-type-value>
<identity-map-class>oracle.toplink.internal.identitymaps.SoftCacheWeakIdentityMap</identity-map-class>
<remote-identity-map-class>oracle.toplink.internal.identitymaps.SoftCacheWeakIdentityMap</remote-identity-map-class>
<identity-map-size>100</identity-map-size>
<remote-identity-map-size>100</remote-identity-map-size>
<should-always-refresh-cache>false</should-always-refresh-cache>
<should-always-refresh-cache-on-remote>false</should-always-refresh-cache-on-remote>
<should-only-refresh-cache-if-newer-version>false</should-only-refresh-cache-if-newer-version>
<should-disable-cache-hits>false</should-disable-cache-hits>
<should-disable-cache-hits-on-remote>false</should-disable-cache-hits-on-remote>
<alias>CustomerVoucherAgreementImpl</alias>
<inheritance-policy>
<descriptor-inheritance-policy>
<parent-class>com.corepass.model.agreement.BaseCustomerAgreement</parent-class>
<should-use-class-name-as-indicator>false</should-use-class-name-as-indicator>
</descriptor-inheritance-policy>
</inheritance-policy>
<interface-policy>
<descriptor-interface-policy>
<parent-interfaces>
<class>com.corepass.model.agreement.Agreement</class>
<class>com.corepass.model.agreement.CustomerAgreement</class>
<class>com.corepass.model.agreement.CustomerAgreementWithFaceValuedSupport</class>
<class>com.corepass.model.agreement.CustomerAgreementWithSupport</class>
</parent-interfaces>
</descriptor-interface-policy>
</interface-policy>
<copy-policy>
<descriptor-copy-policy>
<type>oracle.toplink.internal.descriptors.CopyPolicy</type>
</descriptor-copy-policy>
</copy-policy>
<instantiation-policy>
<descriptor-instantiation-policy>
<type>oracle.toplink.internal.descriptors.InstantiationPolicy</type>
</descriptor-instantiation-policy>
</instantiation-policy>
<query-manager>
<descriptor-query-manager>
<existence-check>Check cache</existence-check>
</descriptor-query-manager>
</query-manager>
<event-manager>
<descriptor-event-manager empty-aggregate="true"/>
</event-manager>
<mappings>
<database-mapping>
<attribute-name>deliveryStructure</attribute-name>
<read-only>false</read-only>
<get-method-name>getDeliveryStructure</get-method-name>
<set-method-name>setDeliveryStructure</set-method-name>
<reference-class>com.corepass.model.agreement.DeliveryStructure</reference-class>
<is-null-allowed>false</is-null-allowed>
<aggregate-to-source-field-name-associations>
<association>
<association-key>DELIVERYNODE_ID</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.DELIVERYNODE_ID</association-value>
</association>
</aggregate-to-source-field-name-associations>
<type>oracle.toplink.mappings.AggregateObjectMapping</type>
</database-mapping>
<database-mapping>
<attribute-name>orderRelatedData</attribute-name>
<read-only>false</read-only>
<get-method-name>getOrderRelatedData</get-method-name>
<set-method-name>setOrderRelatedData</set-method-name>
[b]<reference-class>com.corepass.model.agreement.CustomerAgreementOrderRelatedDataCL</reference-class>[/b]
<is-null-allowed>false</is-null-allowed>
<aggregate-to-source-field-name-associations>
[b]<association>
<association-key>N_MAXREQUESTORDERMONTHDAY</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.N_MAXREQUESTORDERMONTHDAY</association-value>
</association>
<association>
<association-key>N_REMEMBERORDERMONTH_DAY</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.N_REMEMBERORDERMONTH_DAY</association-value>
</association>
<association>
<association-key>D_LASTPERSONALIZEDORDER</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.D_LASTPERSONALIZEDORDER</association-value>
</association>
<association>
<association-key>B_SENDBENEFICIARYLIST</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.B_SENDBENEFICIARYLIST</association-value>
</association>
<association>
<association-key>B_LOADORDERBYNODECODE</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.B_LOADORDERBYNODECODE</association-value>
</association>
<association>
<association-key>B_LOADEXTENDEDORDER</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.B_LOADEXTENDEDORDER</association-value>
</association>
<association>
<association-key>automaticOrderGenerationSpecificationB_AUTOMATICORDERGENERATION</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.B_AUTOMATICORDERGENERATION</association-value>
</association>
<association>
<association-key>B_DELIVERFORM</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.B_DELIVERFORM</association-value>
</association>
<association>
<association-key>automaticOrderGenerationSpecificationQ_AUTOMATICGENERATIONDAY</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.Q_AUTOMATICGENERATIONDAY</association-value>
</association>
<association>
<association-key>D_LASTNOTPERSONALIZEDORDER</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.D_LASTNOTPERSONALIZEDORDER</association-value>
</association>
<association>
<association-key>N_MAX_DELIVERORDERMONTHDAY</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.N_MAX_DELIVERORDERMONTHDAY</association-value>
</association>[/b]
</aggregate-to-source-field-name-associations>
<type>oracle.toplink.mappings.AggregateObjectMapping</type>
</database-mapping>
<database-mapping>
<attribute-name>packagingSpecification</attribute-name>
<read-only>false</read-only>
<get-method-name>getPackagingSpecification</get-method-name>
<set-method-name>setPackagingSpecification</set-method-name>
<reference-class>com.corepass.model.agreement.CustomerAgreementPackagingSpecification</reference-class>
<is-null-allowed>false</is-null-allowed>
<aggregate-to-source-field-name-associations>
<association>
<association-key>STRUCTURE_ID</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.STRUCTURE_ID</association-value>
</association>
</aggregate-to-source-field-name-associations>
<type>oracle.toplink.mappings.AggregateObjectMapping</type>
</database-mapping>
<database-mapping>
<attribute-name>physicalSupportSpecification</attribute-name>
<read-only>false</read-only>
<get-method-name>getPhysicalSupportSpecification</get-method-name>
<set-method-name>setPhysicalSupportSpecification</set-method-name>
<reference-class>com.corepass.model.service.PhysicalSupportSpecificationCL</reference-class>
<is-null-allowed>false</is-null-allowed>
<aggregate-to-source-field-name-associations>
<association>
<association-key>VSMEDIAPHYSICALSUPPORTTYPE_ID</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.VSMEDIAPHYSICALSUPPORTTYPE_ID</association-value>
</association>
<association>
<association-key>VSBENEFICIARYEXPIRATIONTYPE_ID</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.VSBENEFICIARYEXPIRATIONTYPE_ID</association-value>
</association>
<association>
<association-key>VALPERIODTPSPECIF_ID</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT.VALPERIODTPSPECIF_ID</association-value>
</association>
<association>
<association-key>Q_CONSUMPTIONSDAYS</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.Q_CONSUMPTIONSDAYS</association-value>
</association>
<association>
<association-key>VSNOBENEFICIARYEXPTYPE_ID</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.VSNOBENEFICIARYEXPTYPE_ID</association-value>
</association>
<association>
<association-key>Q_MONTHFORCREATEBEFORECONSUMPT</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.Q_MONTHFORCREATEBEFORECONSUMPT</association-value>
</association>
</aggregate-to-source-field-name-associations>
<type>oracle.toplink.mappings.AggregateObjectMapping</type>
</database-mapping>
<database-mapping>
<attribute-name>printingPreferences</attribute-name>
<read-only>false</read-only>
<get-method-name>getPrintingPreferences</get-method-name>
<set-method-name>setPrintingPreferences</set-method-name>
<reference-class>com.corepass.model.agreement.PrintingPreferencesCL</reference-class>
<is-null-allowed>false</is-null-allowed>
<aggregate-to-source-field-name-associations>
<association>
<association-key>COMPANYLOGOCODE</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.COMPANYLOGOCODE</association-value>
</association>
<association>
<association-key>PRINTABLEPHRASE2</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.PRINTABLEPHRASE2</association-value>
</association>
<association>
<association-key>AGREEMENT_ID</association-key>
<association-value>E_CUSTOMER_AGREEMENT.AGREEMENT_ID</association-value>
</association>
<association>
<association-key>PRINTABLEPHRASE1</association-key>
<association-value>E_VOUCHER_CUST_AGREEMENT_CL.PRINTABLEPHRASE1</association-value>
</association>
</aggregate-to-source-field-name-associations>
<type>oracle.toplink.mappings.AggregateObjectMapping</type>
</database-mapping>
</mappings>
<type>oracle.toplink.publicinterface.Descriptor</type>
</descriptor>
The marked elements represents us a difficult problem, 'cause
"com.corepass.model.service.PhysicalSupportSpecificationCL" it's constituted by fields from 2 tables (E_VOUCHER_CUST_AGREEMENT, E_VOUCHER_CUST_AGREEMENT_CL), and we've been trying but the level of inheritance doesn't let us...
This is what we have at the moment.
AbstractAgreement.hbm.xmlCode:
<hibernate-mapping>
<class name="com.corepass.model.agreement.AbstractAgreement" table="E_AGREEMENT" abstract="true">
<id name="id" type="long" column="AGREEMENT_ID" >
<generator class="sequence">
<param name="sequence">AGREEMENT_ID_SEQ</param>
</generator>
</id>
<discriminator column="CLASSINDICATOR" insert="true" not-null="true" type="string"></discriminator>
<property name="active" type="true_false" column="B_ACTIVE" />
<component name="agreementGeneralData" class="com.corepass.model.agreement.AgreementGeneralData" lazy="false">
<property name="comment" column="COMMENTS" type="string" />
<property name="creationDate" column="D_CREATION" type="date" />
<property name="description" column="X_AGREEMENT" type="string" />
<property name="serviceRequestFrequency" column="FREQUENCYTYPE_ID" type="long" />
<property name="validityDate" column="D_VALIDITY" type="date" />
<property name="clientServiceCode" column="CLIENTSERVICECODE" type="long" />
</component>
<property name="agreementType" type="long" column="AGREEMENTTYPE_ID" />
<property name="billingRuleSet" type="long" column="BILLINGRULESET_ID" />
<property name="agreementRoles" type="long" column="AGREEMENTROLESET_ID" />
<property name="commercialDocumentConditions" type="long" column="COMDOCCONDITIONS_ID" />
<property name="company" type="long" column="COMPANY_ID" />
<property name="complete" type="true_false" column="B_COMPLETE" />
<property name="invoicingPointBillableItemTypeAssociationSet" type="long" column="INVPOINTBILLABLEITEMCATSET_ID" />
<property name="lastUser" type="string" column="CHANGEDBY" />
<property name="service" type="long" column="SERVICE_ID" />
<property name="valid" type="true_false" column="B_VALID" />
<property name="version" type="long" column="VERSION" />
</class>
</hibernate-mapping>
BaseCustomerAgreement.hbm.xmlCode:
<hibernate-mapping>
<subclass name="com.corepass.model.agreement.BaseCustomerAgreement" extends="com.corepass.model.agreement.AbstractAgreement" discriminator-value="com.corepass.model.agreement.CustomerVoucherAgreementImplCL" lazy="false">
<join table="E_CUSTOMER_AGREEMENT">
<key column="AGREEMENT_ID"/>
<property name="paymentConditions" type="long" column="PAYMENTCONDITIONS_ID" />
<component name="customerAgreementGeneralData" class="com.corepass.model.agreement.CustomerAgreementGeneralData" lazy="false">
<property name="numberOfBeneficiaries" column="Q_POTENCIALBENEFICIARIES" type="integer" />
<property name="orderOrigins" column="VSORDERORIGIN_ID" type="long" />
<property name="customerCategory" column="CUSTOMER_CATEGORY_ID" type="long" />
</component>
</join>
</subclass>
</hibernate-mapping>
Here we explain the problem in detailCustomerVoucherAgreementImpl.hbm.xmlCode:
<hibernate-mapping>
<subclass name="com.corepass.model.agreement.CustomerVoucherAgreementImpl" extends="com.corepass.model.agreement.BaseCustomerAgreement" discriminator-value="com.corepass.model.agreement.CustomerVoucherAgreementImplCL" lazy="false" >
<join table="[b]E_VOUCHER_CUST_AGREEMENT[/b]">
<key column="AGREEMENT_ID"/>
<property name="deliveryStructure" column="DELIVERYNODE_ID" type="long" />
<component name="orderRelatedData" class="com.corepass.model.agreement.CustomerAgreementOrderRelatedDataCL" lazy="false">
<property name="rememberOrderMonthDay" column="N_REMEMBERORDERMONTH_DAY" type="integer" />
<property name="maximumOrderRequestMonthDay" column="N_MAXREQUESTORDERMONTHDAY" type="integer" />
<property name="maximumOrderDeliveryMonthDay" column="N_MAX_DELIVERORDERMONTHDAY" type="integer" />
<property name="lastPersonalizedOrder" column="D_LASTPERSONALIZEDORDER" type="date" />
<property name="lastNotPersonalizedOrder" column="D_LASTNOTPERSONALIZEDORDER" type="date" />
<!-- This must be filled by E_VOUCHER_CUST_AGREEMENT_CL
<property name="deliverFormOrder" column="B_DELIVERFORM" type="true_false" />
<property name="sendBeneficiaryList" column="B_SENDBENEFICIARYLIST" type="true_false" />
<property name="loadOrderByNodeCode" column="B_LOADORDERBYNODECODE" type="true_false" />
<property name="loadExtendedOrder" column="B_LOADEXTENDEDORDER" type="true_false" />
<component name="automaticOrderGenerationSpecification" class="com.corepass.model.agreement.AutomaticOrderGenerationSpecificationCL" lazy="false">
<property name="automaticGenerationDay" column="Q_AUTOMATICGENERATIONDAY" type="integer"></property>
<property name="automaticGeneration" column="B_AUTOMATICORDERGENERATION" type="true_false"></property>
</component>
-->
</component>
<component name="packagingSpecification" class="com.corepass.model.agreement.CustomerAgreementPackagingSpecification" lazy="false">
<property name="containerStructure" column="STRUCTURE_ID" type="long"></property>
</component>
</join>
<!--
-this is another way, we can fill "orderRelatedData" with E_VOUCHER_CUST_AGREEMENT_CL or E_VOUCHER_CUST_AGREEMENT, but we can't both.
<join table="[b]E_VOUCHER_CUST_AGREEMENT_CL[/b]">
<key column="AGREEMENT_ID"/>
<component name="orderRelatedData" class="com.corepass.model.agreement.CustomerAgreementOrderRelatedDataCL" lazy="false">
-These 5 fields must be filled by E_VOUCHER_CUST_AGREEMENT, but we can use the same attribute "orderRelatedData" twice
-<property name="rememberOrderMonthDay" column="N_REMEMBERORDERMONTH_DAY" type="integer" />
-<property name="maximumOrderRequestMonthDay" column="N_MAXREQUESTORDERMONTHDAY" type="integer" />
-<property name="maximumOrderDeliveryMonthDay" column="N_MAX_DELIVERORDERMONTHDAY" type="integer" />
-<property name="lastPersonalizedOrder" column="D_LASTPERSONALIZEDORDER" type="date" />
-<property name="lastNotPersonalizedOrder" column="D_LASTNOTPERSONALIZEDORDER" type="date" />
<property name="deliverFormOrder" column="B_DELIVERFORM" type="true_false" />
<property name="sendBeneficiaryList" column="B_SENDBENEFICIARYLIST" type="true_false" />
<property name="loadOrderByNodeCode" column="B_LOADORDERBYNODECODE" type="true_false" />
<property name="loadExtendedOrder" column="B_LOADEXTENDEDORDER" type="true_false" />
<component name="automaticOrderGenerationSpecification" class="com.corepass.model.agreement.AutomaticOrderGenerationSpecificationCL" lazy="false">
<property name="automaticGenerationDay" column="Q_AUTOMATICGENERATIONDAY" type="integer"></property>
<property name="automaticGeneration" column="B_AUTOMATICORDERGENERATION" type="true_false"></property>
</component>
</component>
</join>
-->
</subclass>
</hibernate-mapping>
I hope you can do something for us, and thanks for you time.