When I use
Code:
<composite-id class="com.dsii.hibernate.po.UserRoleID" name="userRoleID" >
<key-property name="userNo" column="user_id" type="string"/>
<key-property name="roleNo" column="role_id" type="string"/>
</composite-id>
every thing is OK.
But when use
Code:
<composite-id class="com.dsii.hibernate.po.UserRoleID" name="userRoleID" >
<key-many-to-one name="userNo" class="com.dsii.hibernate.po.User" column="user_id"/>
<key-many-to-one name="roleNo" class="com.dsii.hibernate.po.Role" column="role_id"/>
</composite-id>
I encountered a exception like this:
net.sf.hibernate.MappingException: No persister for: java.lang.String
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.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2755)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:47)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:154)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:836)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:856)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2113)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1987)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1916)
at com.dsii.common.hibernate.HibernateUtil.findById(HibernateUtil.java:36)
at com.dsii.hibernate.po.UserRoleTest.main(UserRoleTest.java:38)
Any suggestion will be very appreciated.
Best Wishes.