I'm currently facing a problem while using composite-element with Hibernate.
I define a composite-element within the class greco.model.to.Masque. ( i.e field masqueChamps ).
When i try to save a Masque object , a " net.sf.hibernate.MappingException: No persister for: greco.model.to.MasqueChamps " exception is thrown.
My composite-element is not mapped explicitely as It seems that hibernate handle it for me .
After reading completely the hibernate reference documentation, and learning the samples provided in this document, I lack information about the use of composite-element.
- Does mapping a composite-element require mapping the composite-element in a separate class or composite-element are mapped implicitely ?
- Does anybody could provide me with a working example of composite-element ?
Any help would be great
Regards
Yann
PS : Related document ( mapping, debug stack ) concerning my problem are included at the end of this post.
Hibernate version: 2.1.4
Mapping documents:
Code:
<class
name="greco.model.to.Masque"
table="MASQUE"
>
...
<set
name="masquesChamps"
table="MASQUECHAMPS"
lazy="true"
cascade="all-delete-orphan" >
<key>
<column name="ID_MASQUE" />
</key>
<composite-element class="greco.model.to.MasqueChamps">
<property name="rangChampsAffiche" type="java.lang.Integer" column="RANGCHAMPSAFFICHE"/>
<property name="timestamp" type="long" column="TIMESTAMP"/>
<many-to-one name="champ" column="ID_CHAMPS" class="greco.model.to.ChampsAffiche"/>
</composite-element>
</set>
</class>
Full stack trace of any exception that occurs: Code:
net.sf.hibernate.MappingException: No persister for: greco.model.to.MasqueChamps
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:344)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2686)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2693)
at net.sf.hibernate.impl.SessionImpl.isSaved(SessionImpl.java:2730)
at net.sf.hibernate.collection.PersistentCollection.getOrphans(PersistentCollection.java:753)
at net.sf.hibernate.collection.Set.getOrphans(Set.java:47)
at net.sf.hibernate.impl.SessionImpl.getOrphans(SessionImpl.java:3247)
at net.sf.hibernate.engine.Cascades.deleteOrphans(Cascades.java:542)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:533)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:951)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at org.springframework.orm.hibernate.HibernateTemplate$11.doInHibernate(HibernateTemplate.java:296)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:293)
at greco.model.dao.MasqueDAOImpl.save(MasqueDAOImpl.java:221)
at java.lang.reflect.Method.invoke(Native Method)
at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:151)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:120)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:140)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:153)
at $Proxy30.save(Unknown Source)
at greco.model.dao.test.MasqueDAOTest$1.doInTransactionWithoutResult(MasqueDAOTest.java:161)
at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:114)
at greco.model.dao.test.MasqueDAOTest.testMy(MasqueDAOTest.java:154)
at java.lang.reflect.Method.invoke(Native Method)
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.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)