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?
|