-->
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.  [ 8 posts ] 
Author Message
 Post subject: formula property set to null
PostPosted: Tue Sep 19, 2006 4:24 pm 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
I have two tables:
Code:
Issue table
id
...

and
Code:
IssueHistoryStatus table
id
issueId
statusId
startDate
endDate


Current issue status is record from IssueHistoryStatus table where endDate=null.

I want to have activeIssueHistoryStatus property in Issue.hbm with value from following SQL:

SELECT IssueHistoryStatus.* from IssueHistoryStatus where
issueId=:ID and endDate is null


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 3:35 am 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
I tried this:
in Issue.hbm
Code:
<many-to-one name="activeIssueHistoryStatus" class="IssueHistoryStatus" property-ref="activeIssueStatus" fetch="select" lazy="true" update="false" insert="false">
           <column name="id"/>
           <formula>null</formula>
</many-to-one>

and in IssueHistoryStatus.hbm

Code:
        <properties name="activeIssueStatus" insert="false" update="false" >
           <property name="issueId" column="ISSUE_ID"   insert="false" update="false" />
           <property name="endDt"   column="END_DT" insert="false" update="false" />
        </properties>

but it doesn't work?

Any help?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 4:33 am 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
So hibernate generate SQL:
Code:
select *
from ISSUE_STATUS_HISTORY imsissuest0_
where imsissuest0_.ISSUE_ID=1 and imsissuest0_.END_DT=null


and I need

Code:
select *
from ISSUE_STATUS_HISTORY imsissuest0_
where imsissuest0_.ISSUE_ID=1 and imsissuest0_.END_DT IS null



any help?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 5:14 am 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
And here is solution:-)
Issue.hbm

Code:
      <many-to-one name="activeIssueStatusHistory" class="IssueStatusHistory" fetch="select" lazy="true" update="false" insert="false" property-ref="activeImsIssueStatus" >
           <formula>(SELECT ish.id FROM Issue_Status_History ish WHERE ish.ISSUE_ID=ID AND ish.end_dt is null)</formula>
        </many-to-one>



IssueHistory.hbm
Code:
        <properties name="activeImsIssueStatus" insert="false" update="false" >
           <property name="id" column="ID"   insert="false" update="false" not-null="true"/>
        </properties>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 22, 2006 3:54 am 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
Solution working but is not good. There are two SQLs

I need this:
in Issue.hbm
Code:
<many-to-one name="activeIssueHistoryStatus" class="IssueHistoryStatus" property-ref="activeIssueStatus" fetch="select" >
           <column name="id"/>
           <formula>null</formula>
</many-to-one>


and in IssueHistoryStatus.hbm
Code:
        <properties name="activeIssueStatus" >
           <property name="issueId" column="ISSUE_ID"   />
           <property name="endDt"   column="END_DT"  />
        </properties>


and I need that hibernate generate:
select *
from ISSUE_STATUS_HISTORY imsissuest0_
where imsissuest0_.ISSUE_ID=1 and imsissuest0_.END_DT IS null

Now it generates:
... imsissuest0_.END_DT = null
Any help? Is this a bug?


Top
 Profile  
 
 Post subject: Same problem as ..
PostPosted: Wed Sep 27, 2006 8:47 am 
Newbie

Joined: Tue Dec 14, 2004 8:30 am
Posts: 9
Hi,

it looks to me that it's the same problem as this one:

http://forum.hibernate.org/viewtopic.php?t=964728&highlight=formula

Did you find a solution ?

Cheers,
Dirk


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 10:21 am 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
No i did not find solution till now :-(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:14 pm 
Newbie

Joined: Tue Dec 14, 2004 8:30 am
Posts: 9
I think, that this jira entry:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-2076

is related to our problem and hope to see the patch in hibernate soon :-))


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