-->
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.  [ 6 posts ] 
Author Message
 Post subject: bug in queryObject.list ?
PostPosted: Fri Feb 11, 2005 1:20 pm 
Newbie

Joined: Tue Aug 24, 2004 5:36 pm
Posts: 16
Hibernate version:2.1.6

As an exemple, I have a base class BaseLabel.java :

public abstract class BaseLabel {
protected String code;
protected Date creationDate;
protected String label;


// setters & getters
// equals & hash
}

public class CountryLabel extends BaseLabel{}
public class SecurityQuestionLabel extends BaseLabel{}


<class name="SecurityQuestionLabel" table="SEC_QUESTION">
<composite-id>
<key-property name="code" column="SQ_COD" length="3"/>
<key-property name="creationDate" column="SQ_CRDAT"/>
</composite-id>
...
</class>

when using query like this :
Query queryObject = createQuery(session, " from SecurityQuestionLabe ");
List list = queryObject.list();

I get

1 11/02/2005 question 1 version 1
1 11/02/2005 question 1 version 1

instead of
1 11/02/2005 question 1 version 1
1 11/02/2005 question 1 version 2


any comments on this ?

thank you in advance


Top
 Profile  
 
 Post subject: Nobody care about this Query.list issue ? FAQ
PostPosted: Mon Feb 14, 2005 6:38 am 
Newbie

Joined: Tue Aug 24, 2004 5:36 pm
Posts: 16
Is it worth to be an item of FAQ for this kind of usage pattern ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 7:23 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You don't give enough info for us to help.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 7:56 am 
Newbie

Joined: Tue Aug 24, 2004 5:36 pm
Posts: 16
emmanuel wrote:
You don't give enough info for us to help.

Really? For exemple ?

I am trying to say that, when I use a class SecurityQuestionLabel extending BaseLabel class as I fully documented, Query.list() method return wrong rows with good number of rows. When I use SecurityQuestionLabel without extending BaseLabel (ie. replicate the members of BaseLabel), I got of course the good rows.

This is a case with a simple class and a simple mapping. I really don't understand what do you mean "enough info" if you don't ask me explicitly.

The use pattern is to have a single base class and extend it to map different tables with the same structure. But this seems to fail with hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 11:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You most likely have a bug in *your* code, but you don't show us the appropriate information:
* equals/hashCode implementation
* your home made createQuery method
* you don't show the real code: your query is broken (no l at the end of SecurityQuestionLabel)
* we don't know what the hell is version

If you want a tip for your problem, have a deep look at how Date is stored and retrieved from your DB. Using data as a PK is plain evil.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 12:30 pm 
Newbie

Joined: Tue Aug 24, 2004 5:36 pm
Posts: 16
Emmanuel, I thank you for this answer with full biblic symbols. That is a helpful answer in the sense of speech action theory and imply an effort of my part. Beside, the holy version of H is mentionned at the first line of my first post.

I'd confess, maintaining someone else's code could become evil if the programming quality does not meet the one that Gavin qualified "sane organisations". The code I posted is a simulacre of some real code for illustrating the use pattern. the "home made" createQuery is from Spring. You are right, the code wouldn't compile nor execute.

During the refactoring of the code, I come to the same point as you have mentionned : the equals method.

So the conclusion is that use pattern works !

Be god with you


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