|
|
|
Hibernate composite-id bag
|
|||
|---|---|---|---|
|
#18+
Такой вопрос: в маппинге есть такой вот composite-id: <composite-id class="PK" name="drilldownPK"> <key-property name="currentColumnName" column="COLUMN_REP_1" type="java.lang.String"/> <key-property name="drilldownColumnName" column="COLUMN_REP_2" type="java.lang.String"/> </composite-id> мне нужно вытянуть bag: <bag name="drilldownReportRoles" lazy="false"> <key column="COLUMN_REP_1" not-null="true"/> <one-to-many class="ReportRole"/> </bag> Кидает вполне обьяснимый эксепшен: Invocation of init method failed; nested exception is org.hibernate.MappingException: Foreign key (FK9D5C38CD54DE7269:TABLE_NAME[COLUMN_REP_1])) must have same number of columns as the referenced primary key (META_DRILLDOWN [COLUMN_REP_1,COLUMN_REP_2]) тогда я сделал еще одну проперти в маппинге: <property name="currentColumnName" column="COLUMN_REP_1" type="String" insert="false" update="false" access="field"/> и изменил bag: <bag name="drilldownReportRoles" lazy="false"> <key property-ref="currentColumnName" not-null="true"/> <one-to-many class="ReportRole"/> </bag> теперь бросает ClassCastException: java.lang.ClassCastException: java.lang.String at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377) at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284) at org.hibernate.loader.Loader.loadCollection(Loader.java:2001) at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454) at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:794) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241) at org.hibernate.loader.Loader.loadEntity(Loader.java:1860) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:179) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795) at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788) at org.springframework.orm.hibernate3.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:508) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:502) at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:496) at com.dvision.business.dao.impl.DrilldownDaoImpl.findById(DrilldownDaoImpl.java:24) 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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at $Proxy9.findById(Unknown Source) at com.dvision.business.dao.impl.DrilldownDaoImplTest.testFindById(DrilldownDaoImplTest.java:36) 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 junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Как быть??В чем моя ошибка? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.08.2007, 19:58:02 |
|
||
|
|

start [/forum/topic.php?fid=59&fpage=618&tid=2144920]: |
0ms |
get settings: |
16ms |
get forum list: |
20ms |
check forum access: |
5ms |
check topic access: |
5ms |
track hit: |
40ms |
get topic data: |
16ms |
get forum data: |
4ms |
get page messages: |
39ms |
get tp. blocked users: |
2ms |
| others: | 304ms |
| total: | 451ms |

| 0 / 0 |
