I'm using Hibernate 3.0.5 and I'm trying to set up a one directional many-to-one association.
The mapping looks like this:
Code:
<class name="NisCode" table="niscode">
<cache usage="read-write" />
<id name="code" type="string" column="code"
unsaved-value="null">
<generator class="assigned" />
</id>
...
<join table="niscode_verwsector" fetch="select" optional="true">
<key column="niscode" unique="true" />
<many-to-one name="verwerkingsSector"
column="key_verwsector" not-null="true" />
</join>
</class>
Code:
2005-10-15 10:23:56,390 DEBUG [net.sf.ehcache.CacheManager] - Attempting to create an existing instance. Existing instance returned.
2005-10-15 10:23:56,390 DEBUG [org.hibernate.cache.CacheFactory] - instantiating cache region: be.vlaanderen.lin.bredero.be.model.code.plaatsBepaling.NisCode usage strategy: read-write
2005-10-15 10:24:18,906 ERROR [org.hibernate.AssertionFailure] - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: table not found
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:433)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:214)
I've run a debugger on it and it seems like the JoinedSubclassEntityPersister does not hold a reference to the joined table "key_verwsector" (which definitely exists) in tableNames, so it bunks out in the getTableId() method. I don't know how or when these tableNames get loaded, so I'm a bit stuck.
Note this
very similar thread o the JBoss forums:
http://jboss.com/?module=bb&op=viewtopic&p=3898032
Also note that everything else works just fine when I remove the <join> mapping.