-->
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.  [ 3 posts ] 
Author Message
 Post subject: Vererbung und Criteria Query
PostPosted: Fri Jun 27, 2008 11:54 am 
Newbie

Joined: Mon Nov 07, 2005 11:30 am
Posts: 7
Hallo,

die Klasse VoAbteilung erbt von VoRevisionSafeObject.
Wenn ich nun mit Criteria Query
from VoAbteilung auf ein geerbtes Attribut "validuntil" von VoRevisionSafeObject einschränken will, kommt:

org.hibernate.QueryException: could not resolve property: validuntil of: de.test.pps.VoAbteilung

VoAbteilung ist als union-subclass gemappt.
Wenn ich from VoRevisionSafeObject abfrage, funzt es.

Wie kann ich einen Query auf die Subklasse machen und auf ein Elternattribut einschränken?

schöne Grüße

Hibernate version:

3.2.5

Mapping documents:
<hibernate-mapping>
<union-subclass name="de.test.pps.VoRevisionSafeBusinessObject" extends="de.test.pps.VoBusinessObject">
<property name="validFrom" column="validfrom" type="timestamp" not-null="true" />
<property name="validUntil" column="validuntil" type="timestamp" not-null="false" />
</union-subclass>
</hibernate-mapping>


<union-subclass name="de.test.pps.VoAbteilung" extends="de.test.pps.VoRevisionSafeBusinessObject" table="abteilung">
<property name="mandant" type="integer" not-null="false" column="mandant" length="4" unique-key="ABTEILUNG_UNIQUE_BUSINESS_KEY"/>
<property name="abteilungsNummer" type="integer" not-null="true" column="abt" length="4" unique-key="ABTEILUNG_UNIQUE_BUSINESS_KEY"/>
<property name="name" type="string" not-null="true" column="ABTEILUNGSNAME" length="20" />
</union-subclass>



Code between sessionFactory.openSession() and session.close():

Criteria crit = session.createCriteria(searchFilter.getClassToFilter());
try {
// if Class to filter is revision save - give back only current data
Class.forName(searchFilter.getClassToFilter().getCanonicalName()).asSubclass(
VoRevisionSafeBusinessObject.class);
if(historicData == false){
logger.debug("Object is revision safe - filtering historic data out");
searchFilter.addFilterCondition(Restrictions.isNull("validuntil"), "validuntil");
}

} catch (ClassNotFoundException e) {
logger.error(e);
return null;
}
List l = crit.list();
session.close();
return l;

Full stack trace of any exception that occurs:

org.hibernate.QueryException: could not resolve property: validuntil of: de.leuka.pps.VoAbteilung
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)

Name and version of the database you are using:

MySql


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 27, 2008 3:58 pm 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Ich denke das Problem ist, dass die Property

validUntil

heisst, du in der Restriction aber

validuntil

angibst.

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject: gelöst
PostPosted: Fri Jun 27, 2008 4:34 pm 
Newbie

Joined: Mon Nov 07, 2005 11:30 am
Posts: 7
shame on me!

ich hatte die Vermutung, daß geerbte Attribute nicht abgefragt werden können,
da ich es in der CodeCompletion nicht gesehen habe.

vielen Dank


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