-->
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.  [ 1 post ] 
Author Message
 Post subject: One-to-one with formula. Bug?
PostPosted: Wed Mar 07, 2007 3:34 am 
Newbie

Joined: Thu Jun 01, 2006 2:15 am
Posts: 7
Hi, forum.

I'm trying to use one-to-one mapping with formula. I have a domain class, within domain there has a list of OU object, but only one OU is root OU which parent ou is null. I want to have root OU in my domain object. So, I define them as:

<class name="Domain" table="DOMAIN">
<id name="id" type="long" column="id">
<generator class="native" />
</id>
<one-to-one name="rootOu" class="OrgUnit" property-ref="rootOu">
<formula>DOMAINID"</foruma>
<formula>'1'</formula>
</one-to-one>
</class>
<class name="OrgUnit" tablel="OrgUnit">
<id name="id" type="long" column="id">
<generator class="native" />
</id>
<properties name="rootOu">
<many-to-one name="domain" class="Domain" fetch="select">
<column name="DOMAINID" not-null="true" />
</many-to-one>
<property name="nullParent" type="boolean">
<formula>case when PARENTID is null then 1 else 0 end</formula>
</property>
</properties>
</class>

It generate currect SQL statement to select domain object, but when load rootOu, the select statement generated is wrong.

for domain object:
select
domain0_.ID as ID1_0_0_,
'1' as formula0_0_
from TEST.DOMAIN domain0_
where domain0_.ID=?

for rootOu:
select
orgunit0_.ID as ID1_2_0_,
orgunit0_.DOMAINID as DOMAINID2_2_0_,
orgunit0_.PARENTID as PARENTID3_2_0_,
case when orgunit0_.PARENTID is null then 1 else 0 end as formula1_0_
from TEST.ORGUNIT orgunit0_
where orgunit0_.DOMAINID=?
and orgunit0_.null=?


As you can see, last line should be: "and orgunit0_.formula1_0_=?", but it generate "and orgunit0_.null=?".

I tried to use "many-to-one" with formula as well. but same thing. It looks like it not work with both side formula?

Am I doing something wrong? Or it's a bug?

Thanks a lot

Noodle


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.