Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write the mapping file ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic