aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to write the mapping file ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to write the mapping file ? " Watch "How to write the mapping file ? " New topic
Author

How to write the mapping file ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I am using hibernate IDE, I found some confusing.

class A {
B b;
B[] b_array;
String[] string_array;
}
class B{...}

---- say "B b";
One solution is
<one-to-one name="b" class="B"/>
anther solution is
<component name="B" ... />

How to write the mapping file ?
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
one thing i like in this forum is the fact that members arent rude as in other java forums; this said, i dont want to rtfm you, but i guess browsing this would help you a lot


java amateur
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
The thing is this, I use Exadel ORMstudio to map object.

I try the simple class just like above. The solution ORMStudio gava to me is "component ..." but I read the book and online tutorial, I think it should be "<one-to-one ..." . You see this difference. This is my confusing. So I post it here to ask for help. Do you think it is rude action ?

I did a lot of homework before I post this question.

Thanks
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
Do you think it is rude action

you misunderstood me!
i never intented to call you rude; i was refering some posters that are rude when answering newbie questions, that's all
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
imagine you'v a class Person and a class Adress; you can map them both as entities - with database identifier; but, if you use what HiA authors call fine grained objects, you may as well map Adress as a component (a hibernate notion).
Read this - they explain it:
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Do you want to be able to access the B objects outside of As? If so, they are entities and will have their own identifier. With that, you can load a B without loading its A. If the B is more like an Address (to use Miguel's example), you may only want to access it from the A. In that case, make it a component.

The problem is that tools cannot know your intended use of the objects, so it simply picks a method to use.
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Originally posted by David Harkness:
Do you want to be able to access the B objects outside of As? If so, they are entities and will have their own identifier. With that, you can load a B without loading its A. If the B is more like an Address (to use Miguel's example), you may only want to access it from the A. In that case, make it a component.

The problem is that tools cannot know your intended use of the objects, so it simply picks a method to use.


you mean, B is only accessed through A , B is sealed in A ---> component
B is indepent object, ---> one-to-one ...

When "component", actually it is ONE table.
When "one-to-one", it is TWO tables.

My understanding is right? Thanks for your help.
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Originally posted by miguel lisboa:
imagine you'v a class Person and a class Adress; you can map them both as entities - with database identifier; but, if you use what HiA authors call fine grained objects, you may as well map Adress as a component (a hibernate notion).
Read this - they explain it:


Thanks for your help. the link you post is very helpful.

Forget about the "rude" things, We are all in the same wonderful java community.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write the mapping file ?