-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: where in class definition not working
PostPosted: Tue Sep 30, 2003 1:29 am 
Newbie

Joined: Tue Sep 30, 2003 12:33 am
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 4:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I very much regret adding this <class where="..."> attribute. Its evil.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 5:00 pm 
Newbie

Joined: Tue Sep 30, 2003 12:33 am
Posts: 2
That may well be the case, but it doesn't help me much.
I'd be happy to have a cleaner mapping solution - if there's one (cleaner = also reasonably simple)- but I don't have the luxury of being able to change the datamodel or do any intrusive changes to the database (except for stored proc but that doesn't work with Hibernate AFAIK)
Regards,
Vlad


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.