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.  [ 5 posts ] 
Author Message
 Post subject: cannot make hibernate to translate class query correctly
PostPosted: Tue Mar 15, 2005 11:22 am 
Beginner
Beginner

Joined: Mon Jan 03, 2005 12:49 pm
Posts: 21
Hi,

I have this mapping:

<hibernate-mapping package="mypackage">
<class name="BaseDocument" table="baseDocument">

<id name="id" type="long" column="id">
<generator class="native"/>
</id>

<property name="name" column="name" type="string"/>
<property name="createDate" column="createDate" type="timestamp"/>
<property name="lastModified" column="lastModified" type="timestamp"/>

</class>
</hibernate-mapping>


And this mapping, that inherits from the previous one

<hibernate-mapping package="mypackage" default-cascade="none">

<joined-subclass name="ExtendedDocument" extends="BaseDocument">

<key column="extendedDocumentId" />

<property name="data" type="string" />

</joined-subclass>

</hibernate-mapping>

I send this HQL query:

SELECT extendedDocument FROM ExtendedDocument AS extendedDocument
WHERE extendedDocument.active = true AND
(extendedDocument.class = mypackage.extendedDocument) AND
extendedDocument.createDate >= :minorDate AND
extendedDocument.createDate <= :majorDate
ORDER BY extendedDocument.createDate DESC

I don't know why, but the class name is ALWAYS translated to 0, even when this is not correct, because when it looks for the class of these rows, Hibernate traduces the instances to class number "1" instead of "0". The only problem is the criteria, that is always 0.

Thanks

Hibernate version:
2.1.7
Mapping documents:
See
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
SQL Server 2000
The generated SQL (show_sql=true):
See
Debug level Hibernate log excerpt:
N/A


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 11:57 am 
Beginner
Beginner

Joined: Mon Jan 03, 2005 12:49 pm
Posts: 21
I'm puzzled...
anyone ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I have no idea what you are talking about


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 12:10 pm 
Beginner
Beginner

Joined: Mon Jan 03, 2005 12:49 pm
Posts: 21
I have three classes, A, B and C. B and C inherit from A. I try to send a query to only obtain subclass B like this:

SELECT A as a FROM A where a.class = <package>.B

When Hibernate traduces it to propietary SQL it does transformations to get a "discriminator" for the joined subclass, it assigns "0" for A, "1" for B and "2" for C in a field of the query (Using "case" in the SQL Server realm). My criteria class = <package>.B is traduced to class= 0 insted of class = 2 that it would be the correct thing, if I am right.

What am i doing wrong ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 1:53 pm 
Beginner
Beginner

Joined: Mon Jan 03, 2005 12:49 pm
Posts: 21
I spent a lot of time searching this problem in the forums but it doesn't seem to be happening to others...

Anyone ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.