Hi,
I have a following definition problem:
I have a generic table (legacy system, so I _cannot_ change my schema) that contains all sorts of code tables in something like name/value and further split by codetable name.
I tried to do this:
<class
name="TermCode"
table="codetable_domains"
schema="dbo"
mutable="false"
where="domain_name='term_domain'"
>
<id
name="term"
column="enum"
type="int">
<generator class="assigned"/>
</id>
<property name="termCode"
column="domain_code"
type="java.lang.String"/>
</class>
And in my referencing class I put :
<many-to-one
name="termCode"
column="index_term"
lazy="false
class="TermCode"/>
</subclass>
into one of the classes using this code value, I get "more than one row found". Which is true, because the query looks like:
from dbo.codetable_domains termcode0_ where termcode0_.enum=?
when I'd expect my where condition (defined in the TermCode mapping definition) to be included - i.e. something like:
from dbo.codetable_domains termcode0_ where termcode0_.domain_name='term_domain' and termcode0_.enum=?
which would return only one value.
Subclassing (Creating a code class and then TermCode with discriminator value term_domain) doesn't seem to work either - I guess the check on size of the result set is done quite early (so even if the collection has only one result of the right type.. not to mention this could get quite ugly).
Anyway, what am I doing wrong? I tried both 2.0.3 and about a week old snapshot. When I tried to debug this, I found that it was setting the where in RootClass, but nothing seemes to call getSQLWhereString on AbstractEntityPersister for this (nor hasWhere for the matter.. ). Maybe a bug?
Also, is there any nice way to use Hibernate to load codetables? (just a map of key/value elements - or a wrapper class around the map.)
Thanks,
Vlad
|