I have a problem with 3 tables which reference one field in a 4th table. Only one of the tables references the field. It`s primary key should be written in the fkey field of table 4. The problem is that there is only a null value there.
Hibernate version:
3.1.2
Tables:
There are 4 Tables:
Table1:
pkey
data1
Table2:
pkey
data2
Table3:
pkey
data3
Table4:
pkey
fkey
data4
Mapping:
Table1,2,3:
...
<set name="table4" inverse="true" cascade="all-delete-orphan">
<key>
<column name="FKEY" precision="20" scale="0" />
</key>
<one-to-many class="table4" />
</set>
...
Table4:
<class name="table4" table="xxx" schema="xxx">
<id name="pkey" type="java.lang.Long">
<column name="PKEY" precision="20" scale="0" />
<generator class="sequence">
<param name="sequence">SEQ</param>
</generator>
</id>
<many-to-one name="table1" class="table1" fetch="select">
<column name="FKEY" precision="20" scale="0" />
</many-to-one>
<many-to-one name="table2" class="table2" update="false" insert="false" fetch="select">
<column name="FKEY" precision="20" scale="0" />
</many-to-one>
<many-to-one name="table3" class="table3" update="false" insert="false" fetch="select">
<column name="FKEY" precision="20" scale="0" />
</many-to-one>
<property name="data4" type="string">
<column name="data4" length="64" />
</property>
</class>
If i delete -update="false" insert="false"- in the other 2 many-to-one relations I get the following error:
Error:
2006-06-12 12:03:45,522 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/SamCore.UserDataService]] - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx' defined in ServletContext resource [/WEB-INF/conf/dev/persistence.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is java.lang.ExceptionInInitializerError: null]
PropertyAccessExceptionsException (1 errors)
org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is java.lang.ExceptionInInitializerError: null
java.lang.ExceptionInInitializerError
at com.infineon.persistence.hibernate.HibernateContext.init(HibernateContext.java:91)
at com.infineon.persistence.hibernate.HibernateContext.setProperties(HibernateContext.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:596)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:469)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:626)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:653)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1023)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3727)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4162)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: table4 column: FKEY (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:597)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:615)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
at com.infineon.persistence.hibernate.HibernateContext.init(HibernateContext.java:79)
... 36 more
Name and version of the database you are using:
Oracle (9 or 10)
xml structure:
<table1 pkey="" data1="">
<table4 pkey="" data4="" fkey="pkey_table1">
</table4>
</table1>
<table2 pkey="" data2="">
<table4 pkey="" data4="" fkey="pkey_table2">
</table4>
</table2>
<table3 pkey="" data3="">
<table4 pkey="" data4="" fkey="pkey_table3">
</table4>
</table3>
Do you know what else to write in the mappingfile/s?
Judith
|