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.  [ 2 posts ] 
Author Message
 Post subject: Problem With Joined Subclass
PostPosted: Tue Sep 04, 2007 11:04 am 
Newbie

Joined: Tue Sep 04, 2007 10:51 am
Posts: 2
Location: Tacoma, WA
Hi,

I have a domain model like this:

Program--|>ManagerAssignment--|>Assignment<--Portfolio

Code:
<class name="Assignment">
   <id name="_id" access="field">
      <column name="ID" sql-type="int" not-null="true" />
      <generator class="identity" />
   </id>
    ...
</class>

<joined-subclass name="ManagerAssignment" extends="Assignment">
   <key column="AssignmentID" />
   ...
</joined-subclass>

<joined-subclass name="Program" extends="ManagerAssignment">
    <key column="AssignmentID" />
    ...
</joined-subclass>

<class name="Portfolio">
   <id name="_id" access="field">
     <column name="ID" sql-type="int" not-null="true" />
     <generator class="identity" />
   </id>

   <many-to-one name="Assignment" column="AssignmentID" />
   <property name="EffectiveDate" />
   ...
</class>


I want to get the portfolio for a program on a specific date:
Code:
from Portfolio where Assignment = :program and EffectiveDate = :effectiveDate


This generates the following SQL:
Code:
select
  portfolio0_.ID as ID3_,
  portfolio0_.AssignmentID as Assignme2_3_,
  portfolio0_.EffectiveDate as Effectiv3_3_
from
  Portfolio portfolio0_
where
  (0=@p0 )
  and(EffectiveDate=@p1 );


where @p0 is something like 1234, the AssignmentID for the program I want a portfolio for. I am confused by the
Code:
(0=@p0)
part.

I stepped through the NHibernate source code and saw where, in JoinedSublcassPersister, it refers to this 0 as the discriminator. I thought discriminators were only for single table inheritence?

Of course the above SQL query returns no results.

Any advice or help much appreciated. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 11:52 am 
Newbie

Joined: Tue Sep 04, 2007 10:51 am
Posts: 2
Location: Tacoma, WA
Update: Changing to using the program's ID property for the query works fine. In other words:
Code:
from Portfolio where AssignmentID = :programID

with
Code:
query.SetParameter("programID", program.ID)


I'd still like to know why querying with the object doesn't work, as I am using objects as parameters in many other places and this is the first time I've seen this.


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