I'm still trying to create the ID scheme laid out here:
http://forum.hibernate.org/viewtopic.php?t=61
I'm so close to finishing I can taste it. :) Unfortunately I've come upon a glitch I can't seem to get around.
The problem is that when I try to put a many-to-one relationship in the ID, whether I use a custom id or composite-id with a key-many-to-one attribute, I get a net.sf.hibernate.MappingException.
Mapping:
Code:
<composite-id unsaved-value="any">
<key-property name="id" type="long"/>
<key-many-to-one name="site" class="com.foo.bar.data.sites.Site"/>
</composite-id>
Exception thrown at runtime:
Code:
net.sf.hibernate.MappingException: No persister for: com.foo.bar.data.sites.Site
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:337)
at net.sf.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:472)
at net.sf.hibernate.type.ManyToOneType.getColumnSpan(ManyToOneType.java:21)
at net.sf.hibernate.type.ComponentType.getColumnSpan(ComponentType.java:58)
at net.sf.hibernate.persister.NormalizedEntityPersister.<init>(NormalizedEntityPersister.java:719)
at net.sf.hibernate.persister.PersisterFactory.create(PersisterFactory.java:32)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:141)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:657)
at com.foo.bar.data.access.DataAccess.makeSessionFactory(DataAccess.java:70)
at com.foo.bar.data.access.DataAccess.<clinit>(DataAccess.java:22)
at HibernateTest.main(HibernateTest.java:102)
When I have a custom ID type I get the same exception with
Code:
at net.sf.hibernate.type.CompositeCustomType.getColumnSpan(CompositeCustomType.java:122)
instead of
Code:
at net.sf.hibernate.type.ComponentType.getColumnSpan(ComponentType.java:58)
The mapping for Site is in the same mapping file as the problem class, so I know it's loaded. Also, I can have a normal many-to-one tag in the same class without problems.
I think this may be related to a recent issue logged in JIRA:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?id=10331
The issue is marked closed and fixed, but the atteched comments seem to indicate that there are still problems.
Except in cases where I have custom types, I'n generating all java code and DDL from the mapping file.
I'm using version 2.1 beta 2.
Thanks!