-->
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: possible major bug in hibernate 2.1.3
PostPosted: Fri May 07, 2004 9:00 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
We started developing a medium web application (appr. 30k LOC) with hibernate about 9 months ago.

in the beginning we struggled quite a bit and had some problems with synchronizing objects between sessions, mapping stuff and so on. but after some time we really started loving hibernate and i think we accumulated quite a bit of knowledge and best practices in this area.

about 2 days ago i realized, that there's a new version out and downloaded it. after i installed it our application suddenly started throwing ClassCastExceptions. we had a look into it and i found out, that hibernate sometimes seems not to translate queries properly anymore.

for a simple

'select user from User as user'

the following sql statement is generated

'select user as x0_0_ from tbUser user0_ inner join tbActor user0__1_ on user0_.userActorID=user0__1_.actorID'

which returns a List of Strings instead of Users.

The mapping is as follows

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="de.sag.qsee.masterdata.data.Actor" table="tbActor">
<!-- config -->
<cache usage="read-write"/>
<!-- PK -->
<id name="actorID" column="actorID" type="int" unsaved-value="0">
<generator class="identity"/>
</id>
<!-- subclasses -->
<!-- User class -->
<joined-subclass name="de.sag.qsee.masterdata.userdata.data.User" table="tbUser">
<key column="userActorID"/>
<property name="status" column="status" type="int"/>
<property name="lastName" column="lastName" type="string"/>
<property name="firstName" column="firstName" type="string"/>
<property name="userName" column="userName" type="string"/>
<property name="loginName" column="loginName" type="string"/>
<property name="password" column="password" type="string"/>
<property name="numberFailedLogins" column="numberFailedLogins" type="int"/>
<property name="phone" column="phone" type="string"/>
<property name="fax" column="fax" type="string"/>
<property name="electronicMail" column="electronicMail" type="string"/>
<property name="isSalesAmiabilityOriginator" column="isSalesAmiabilityOriginator" type="boolean"/>
<property name="salesAmiabilityNo" column="salesAmiabilityNo" type="string"/>
<many-to-one name="language" column="languageID" not-null="true"/>
<many-to-one name="country" column="countryID" not-null="true"/>
<many-to-one name="currentRole" column="currentRole" not-null="false"/>
<bag name="roles" table="tbUser2Role" lazy="true">
<key column="userActorID"/>
<many-to-many class="de.sag.qsee.masterdata.userdata.data.Role" column="tbRoleID"/>
</bag>
<!-- subclasses -->
<!-- Technician class -->
<joined-subclass name="de.sag.qsee.masterdata.userdata.data.Technician" table="tbTechnician">
<key column="technicianActorID"/>
<!-- local attributes -->
<property name="technicianNo" column="technicianNo" type="string"/>
<property name="shortMark" column="shortMark" type="string"/>
<property name="mobilePhone" column="mobilePhone" type="string"/>
<property name="birthday" column="birthday" type="date"/>
<property name="collectionAccount" column="collectionAccount" type="string"/>
<property name="carNumber" column="carNumber" type="string"/>
<!-- one to many -->
<bag name="repairTypes" table="tbTechnicianQualification" lazy="true">
<key column="technicianActorID"/>
<many-to-many class="de.sag.qsee.masterdata.oemdata.data.RepairType" column="tbRepairTypeID"/>
</bag>
<bag name="addresses" table="tbAddress" inverse="true" lazy="true" cascade="all">
<key column="actorID"/>
<one-to-many class="de.sag.qsee.masterdata.data.Address"/>
</bag>
<bag name="workingDays" table="tbTechnicianWorkingDays" inverse="true" lazy="true">
<key column="technicianActorID"/>
<one-to-many class="de.sag.qsee.masterdata.userdata.data.TechnicianWorkingDay"/>
</bag>
<bag name="appointments" table="tbTechnicianAppointmentSlots" inverse="true" lazy="true">
<key column="technicianActorID"/>
<one-to-many class="de.sag.qsee.taskscheduler.data.TechnicianAppointmentSlot"/>
</bag>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>


The strange thing about it is, if i do the same for Technicians, which is a subclass of User, it works fine.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 9:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
"user" in the select clause is now a recognized keyword for some databases (hsql, oracle). Just use "select uzer from User uzer". This is kind of a bug, aliases should really override sql functions.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 9:05 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
I just realized something.

If I drop the 'select user' and write

'from User as user' instead

everything works fine.

how's that possible?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 9:31 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
all right, that explains a lot ;-)

thx for the quick answer!


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.