-->
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.  [ 4 posts ] 
Author Message
 Post subject: Session.get(): Issue or undocumented feature ...
PostPosted: Tue Mar 22, 2005 4:37 pm 
Newbie

Joined: Thu Nov 18, 2004 10:07 am
Posts: 7
Looking for bug in our program, I spotted something, which is either a bug in Hibernate or simply undocumented Feature. We are using Hibernate 2.1.7, jTDS and SQLServer.

First, there was a bug in our program, where a false id was provided to an internal method. This method called the Session.get() with the false id and the result was not what one might expect.

Well, actually it was our fault to provide a false id and we have already corrected this, but may be somebody is curious and can look into the following. Here is the (very simplified) scenario to reproduce it:

There are three classes, say A, B and C, where A is the root class, B is subclass of A, C is subclass of A (note: C is no subclass of B, also B is not subclass of C). All this three classes are saved in a single table using the mapping

<class name=”A” table=”atable” discriminator-value=”A”>
<id type="long" name="id" unsaved-value="0">
<generator class="foo.CommonHiLoGenerator"/>
</id>
<discriminator column="subclass" type="character"/>
<subclass name=”B” discriminator-value=”B”/>
<subclass name=”C” discriminator-value=”C”/>
</class>

Create at least one instance from each class, say A(id=1), B(id=2), C(id=3).

When calling Session.get(B.class, new Long(1)) with a false Id, I expected to get null or at least an exception from hibernate, because there is no instance of B with id=1. But the method simply returns a correct object for the given id – here A(id=1). I try it even with Session.get(B.class, new Long(3)) and I get the correct instance of C(id=3). Is this an issue, or is this simply a undocumented feature? Or am I blind and I wasn't able to find this documented (sorry if so)?

With best regards
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 5:29 pm 
Newbie

Joined: Thu Nov 18, 2004 10:07 am
Posts: 7
The hibernate version we are using is actually 2.1.8, but the jar from 3.01.2005, which is contained within the official 2.1.8 destribution, has a manifest with a wrong version - 2.1.7.

Regards
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 5:40 pm 
Newbie

Joined: Thu Nov 18, 2004 10:07 am
Posts: 7
Oh, something completely different: Is it possible, that the message time of the forum server (see "Posted:") is not quite correct? I thing the clock is about 20-25 minutes faster... yes, I know, this is a common problem within Internet.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 5:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Nothing to do with the internet, timesync wasn't started on the forum server on last reboot. Fixed now.


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