-->
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: ISession.Find on the value of an abstract property
PostPosted: Sat Sep 17, 2005 4:27 pm 
Newbie

Joined: Sat Sep 17, 2005 3:52 pm
Posts: 2
I've got an abstract Employee class with an abstract "SystemName" property. I have two subclasses of Employee, RegularEmployee and ContractorEmployee, both of which implement the SystemName property. I'm attempting to call ISession.Find with a query string like so:

Code:
"from Employee as e where e.SystemName = \'rdkinde\'"


NHibernate is failing on the call to Find with the following message:

Code:
NHibernate.QueryException : could not resolve property:SystemName of :Domain.Employee [from Domain.Employee as e where e.SystemName = 'rdkinde']


However, if I change the query string to query the concrete class, it works fine:

Code:
"from RegularEmployee as e where e.SystemName = \'rdkinde\'"


Is it possible to query on the value of an abstract property value from it's abstract class, as I've tried to do? If so, how would I need to structure the hbm.xml files to facilitate this functionality?

_________________
---

Ryan Kinderman


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 9:03 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Does the mapping for your Employee class contain the mapping for SystemName property?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 2:02 am 
Newbie

Joined: Sat Sep 17, 2005 3:52 pm
Posts: 2
sergey wrote:
Does the mapping for your Employee class contain the mapping for SystemName property?


Sorry for the belated reply, thought I had it set up to e-mail me when a response was posted.

Anyways, thanks for the response. To answer your question:

No, the Employee mapping does not include a property mapping for the SystemName property. The reason is because the subclass tables (ContractorEmployee and RegularEmployee) each have a different column name that populates the derived SystemName property. So, if I were to put <property name="SystemName" ... /> in the Employee mapping, I could not include the "column" attribute, because it differs for each subclass.

I currently have the "SystemName" property mapping in each of the subclass mappings, which allows me to specify the different column names. I figured that NHibernate might be able to determine this possibility. Would it work if the column names in both of the subclass tables were the same? Would that allow me to add the property mapping to the Employee map, or would NHibernate only look in the superclass table for the column?

BTW, I'm using "table-per-subclass", in case that wasn't evident.

Thanks!

_________________
---

Ryan Kinderman


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.