I have a strange problem using Hibernate 3.3.1.ga with Spring DM 1.2.0-rc1.
Code:
Hibernate generates the following error :
smx@rootsgi> org.hibernate.MappingException: Unknown entity: org.apache.camel.example.reportincident.model.Inci dent
at org.hibernate.impl.SessionFactoryImpl.getEntityPer sister(SessionFactoryImpl.java:580)
at org.hibernate.impl.SessionImpl.getEntityPersister( SessionImpl.java:1365)
at org.hibernate.engine.ForeignKeys.isTransient(Forei gnKeys.java:203)
at org.hibernate.event.def.AbstractSaveEventListener. getEntityState(AbstractSaveEventListener.java:535)
at org.hibernate.event.def.DefaultSaveOrUpdateEventLi stener.performSaveOrUpdate(DefaultSaveOrUpdateEven tListener.java:103)
at org.hibernate.event.def.DefaultSaveOrUpdateEventLi stener.onSaveOrUpdate(DefaultSaveOrUpdateEventList ener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(Se ssionImpl.java:534)
at org.hibernate.impl.SessionImpl.saveOrUpdate(Sessio nImpl.java:526)
at org.hibernate.impl.SessionImpl.saveOrUpdate(Sessio nImpl.java:522)
at org.apache.camel.example.reportincident.dao.impl.I ncidentDAOImpl.saveIncident(IncidentDAOImpl.java:1 01)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
at org.springframework.osgi.service.importer.support. internal.aop.ServiceInvoker.doInvoke(ServiceInvoke r.java:58)
at org.springframework.osgi.service.importer.support. internal.aop.ServiceInvoker.invoke(ServiceInvoker. java:62)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.osgi.service.util.internal.aop .ServiceTCCLInterceptor.invokeUnprivileged(Service TCCLInterceptor.java:56)
at org.springframework.osgi.service.util.internal.aop .ServiceTCCLInterceptor.invoke(ServiceTCCLIntercep tor.java:39)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.osgi.service.importer.support. LocalBundleContextAdvice.invoke(LocalBundleContext Advice.java:59)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy29.saveIncident(Unknown Source)
at org.apache.camel.example.reportincident.service.im pl.IncidentServiceImpl.saveIncident(IncidentServic eImpl.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy30.saveIncident(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
at org.springframework.osgi.service.importer.support. internal.aop.ServiceInvoker.doInvoke(ServiceInvoke r.java:58)
at org.springframework.osgi.service.importer.support. internal.aop.ServiceInvoker.invoke(ServiceInvoker. java:62)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.osgi.service.util.internal.aop .ServiceTCCLInterceptor.invokeUnprivileged(Service TCCLInterceptor.java:56)
at org.springframework.osgi.service.util.internal.aop .ServiceTCCLInterceptor.invoke(ServiceTCCLIntercep tor.java:39)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.osgi.service.importer.support. LocalBundleContextAdvice.invoke(LocalBundleContext Advice.java:59)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy99.saveIncident(Unknown Source)
at org.apache.camel.example.reportincident.beans.Csv. process(Csv.java:48)
Here is the config used :
1) Bundle Model
Inicident.hbm.xml file is deployed in a bundle under the directory : META-INF/org/apache/camel/example/reportincident/model
The directory containing the files is exported in the MANIFEST file of this bundle :
Code:
Export-Package = org.apache.camel.example.reportincident.model;uses :="org.apache.commons.lang.builder,org.apache.came l.dataformat.bindy.annotation",META-INF.org.apache.camel.example.reportincident.model
2) Bundle persistence
The bean org.springframework.orm.hibernate3.LocalSessionFactoryBean is created in other bundle called persistence
The config of the LocalSessionFactoryBean is the following :
Code:
<!-- Hibernate SessionFactory Definition -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="mappingDirectoryLocations">
<list>
<value>classpath*:META-INF/org/apache/camel/example/reportincident/model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">tru e</prop>
<prop key="hibernate.cache.provider_class">org.hibernate .cache.EhCacheProvider</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
Where is the issue ?
Regards,
Charles Moulliard
__________________