-->
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: one-to-one map on arbitarary columns on both classes
PostPosted: Wed Apr 07, 2004 7:06 am 
Newbie

Joined: Mon Apr 05, 2004 3:14 am
Posts: 13
hi,

Hibernate 2.1

i am a Hibernate beginner. my problem is as follows:

1. table item_master->field part_category_id has one-to-one relation with table part_category_master->field part_category_id.

item_master primary key is part_id.

i need to set one-to-one relation in item_master table map, on the basis of item_master->part_category_id = part_category_master->part_category_id.

Hibernate keeps trying to set up relation on the basis of item_master->part_id to part_category_master.part_category_id.

because, item_master primary key is part_id.

i need to set up such a relation so that i can read part_category_desc from item_master using left outer join.

i checked documentation and i have found no obvious answer.

what mapping element should i use ?

any help/tips are welcome.

thanks in advance.

iyyappan

This is long page. pls remember that you had asked for details.

-- Following produces null for part_category_desc, when i write

select part_category_master.part_category_desc from item_master left join part_category_master as part_category_master
where item_master.part_category_id = part_category_master.part_category_id

(i know one-to-many is not ok.)
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="item_master" table="item_master" >
<id name="part_id" type="string">
<generator class="assigned"/>
</id>
<set name="part_category_desc" lazy="true" inverse="false"
cascade="none" >
<key column="part_category_id" />
<one-to-many
class="apparelxml.part_category_master"
/>
</set>
</class>

</hibernate-mapping>

---------------
Map 2:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="item_master" table="item_master" >
<id name="part_id" type="string">
<generator class="assigned"/>
</id>
<one-to-one name="part_category_desc" class="apparelxml.part_category_master" cascade="none" />
</class>

</hibernate-mapping>

produces the following error :

2 errors occurred while listing (and calling getPathNames).
net.sf.hibernate.QueryException: outer or full join must be followed by path expression [select part_category_master.part_category_desc from apparelxml.item_master left join part_category_master as part_category_master
where item_master.part_category_id = part_category_master.part_category_id]
net.sf.hibernate.QueryException: outer or full join must be followed by path expression [select part_category_master.part_category_desc from apparelxml.item_master left join part_category_master as part_category_master
where item_master.part_category_id = part_category_master.part_category_id]

for the following sql :


select part_category_master.part_category_desc from item_master left join part_category_master as part_category_master
where item_master.part_category_id = part_category_master.part_category_id


Top
 Profile  
 
 Post subject: if i tried formula property ...
PostPosted: Wed Apr 07, 2004 8:20 am 
Newbie

Joined: Mon Apr 05, 2004 3:14 am
Posts: 13
hi,

to read a value from another table i have created a formula field.

<property
name = "part_category_desc"
formula = "(select part_category_master.part_category_desc from part_category_master as part_category_master,item_master as item_master where part_category_master.part_category_id= item_master.part_category_id)"/>

Hibernate asks for getter and setter for part_category_desc property,
which is not needed for formula properties.

if i placed a getter / setter then Hiberbnate, gives the following message:

net.sf.hibernate.QueryException: could not resolve property: part_category_desc of: apparelxml.item_master [select item_master.part_category_desc from apparelxml.item_master as item_master]

(Hibernate is looking in database ? )

on dos console no error is displayed. i am using Hiber8Ide .

If i removed the formula field , maps for both the tables work ok.

Thanks in advance for any help.

iyyappan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:04 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
use property-ref

_________________
Emmanuel


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.