-->
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: i have some puzzle with why use "many-to-one"?
PostPosted: Sun Jun 06, 2004 11:13 pm 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
i have some puzzle with "many-to-one", "one-to-many", "many-to-many"

now, i use the mapping files without such as "many-to-one",
so i can use HQL expression like SQL .

for example ,

if the mapping without "many-to-one"
i can write code as :
select a.m, a.x, b.y from A a, B b where a.m=b.m and a.n=b.n

a.m , a.n is a foreign key , b.m and b.n is a composite primary key

but
the mapping file for table A created by middlegen has element "many-to-one". and class A has no field name like "m" or "n"

so i can't write HQL like
"select a.m, a.x, b.y from A a, B b where a.m=b.m and a.n=b.n"
because Class A for table A has no property named "m"

i think that isn't intuitionistic. and perhaps it will effect replantting.

>>>i've write many codes with mapping without "many-to-one".
if i change to use "many-to-one" , i seems i must rewrite the codes.
i don't want to do that. is there anything i did wrong. or there has a better solution?

>>> i don't know how to ask this question better. i wish someone could understand what i means.

_________________
I am the creatxr of world.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 12:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If you map the reationship then Hibernate can automatically load the relationship data and populate the Java Classes for you. You can use a query as well (depending on the database and lazy settings if might not any more efficient). An OR mapper allows you to think more about you Java domain model rather than the relational model.


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.