I'm upgrading a large system from Spring 2.5 to 4.3. We use also a quiete old Hibernate version 3.2.6.ga. After many problems with an upgrade to Hibernate 4, i've decided to stay at the latest Hibernate 3 version.
But.. there are constructs which are not functional anymore. We use composite foreign keys, which are referencing nonprimary keys. (s.
http://learningviacode.blogspot.nl/2012 ... ncing.html)
Thats my construct
Code:
<class name="ApLocation" table="AP_LOCATION"
lazy="true" dynamic-update="true" optimistic-lock="dirty">
<meta attribute="extends">EntityObjectWithIdTs</meta>
<meta attribute="implements">EntityWithMandator</meta>
<id name="id" type="java.lang.Long" column="ID_LOCATION" length="22">
<generator class="IdGeneratorTable" />
</id>
<discriminator
formula="case when PERSON_INSTITUTION = 'IP' then 'C' else 'A' end" />
....
<property name="bpId" column="ID_JURISTIC_PERSON" type="java.lang.Long"
insert="false" update="false" />
<property name="addrId" column="ID_ADDRESS" type="java.lang.Long"
insert="false" update="false" />
<properties name="comp_BpAddr" insert="false" update="false" unique="false">
<property name="bpId" column="ID_JURISTIC_PERSON" type="java.lang.Long"
insert="false" update="false" />
<property name="addrId" column="ID_ADDRESS" type="java.lang.Long"
insert="false" update="false" />
</properties>
....
<subclass name="ApAddressLocation"
extends="ApLocation"
discriminator-value="A" dynamic-update="true">
<set name="apContactPersonLocations" lazy="true"
where="PERSON_INSTITUTION = 'IP'" inverse="true" >
<key property-ref="comp_BpAddr" unique="false" >
<column name="ID_JURISTIC_PERSON"/>
<column name="ID_ADDRESS" />
</key>
<one-to-many class="ApContactPersonLocation"/>
</set>
</subclass>
<subclass name="de.klopotek.mex.bus.ap.entity.ApAddressLocation"
extends="de.klopotek.mex.bus.ap.entity.ApLocation"
discriminator-value="A" dynamic-update="true">
<set name="apContactPersonLocations" lazy="true"
where="PERSON_INSTITUTION = 'IP'" inverse="true" >
<key property-ref="comp_BpAddr" unique="false" >
<formula>ID_JURISTIC_PERSON</formula>
<formula>ID_ADDRESS</formula>
</key>
<one-to-many class="ApContactPersonLocation"/>
</set>
</subclass>
At startup the following exception is thrown
Code:
Caused by: org.hibernate.MappingException: property [comp_BpAddr] not found on entity [ApAddressLocation]
at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:379)
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2533)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2782)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:660)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:191)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 52 more
Any ideas how i can solve this problem?