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: Mapping 2 objects from the same table. 1 obj consists second
PostPosted: Wed Mar 05, 2008 5:03 am 
Newbie

Joined: Wed Mar 05, 2008 4:52 am
Posts: 1
Hi.

Is there possibility to do something like this:

I've got one table T1:
|ID|NAME|STEP|

and now I want to mapp this structure:

class A {
private long id;
private String name;
private B step;

//getters setters
}

where id is ID from T1, name is NAME from T1 and class B looks like this:

class B {
private String step;

//getters setters
}

where step is STEP from table T1.

And my second question: what about id in class B ?

Any suggestions ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 10, 2008 7:15 am 
Newbie

Joined: Fri Feb 29, 2008 1:07 pm
Posts: 5
I think you do not need to set an "id"; for B just use a <component> in the A class hibernate mapping file, and it'll be enough.

like here: http://www.hibernate.org/hib_docs/v3/re ... entobjects

so you'll have
Code:
<class name="A" table="T1">
    <id name="id" column="ID" type="...">
        <generator ... /></generator>
    </id>
    <property name="name" column="NAME" ... />
    <component name="Step" class="B" unique="true">
        <property name="step" column="STEP" type="..." />
    </component>
</class>


thanks for rating this answer!

Maxx


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.