-->
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.  [ 4 posts ] 
Author Message
 Post subject: mapping
PostPosted: Wed Aug 17, 2005 10:02 am 
Beginner
Beginner

Joined: Wed Aug 10, 2005 4:22 am
Posts: 24
class User
{
private String name;
.....
....
private java.util.Vector roles = new Vector();
}

class Role
{
private String roleName;
.....
....
}

How can I write mapping documents for this classes. Is there any way to save vectors?

thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 10:14 am 
Newbie

Joined: Mon Jun 06, 2005 8:21 am
Posts: 13
Here's one way, I think. Though with Set, not a Vector. You may use Set, List, Map.

See the reference for more options.

Code:
<class name="User" table="user">
   <id name="name">
       <column name="name" />
            <generator class="assigned"/>
        </id>   
       
   <set name="roles" table="Role">
      <key column="id" />
      <one-to-many class="Role"/>
   </set>   
</class>

<class name="Role" table="role">
   <id name="roleName">
       <column name="roleName" />
            <generator class="assigned"/>
        </id>
       
</class>



Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 2:42 am 
Beginner
Beginner

Joined: Wed Aug 10, 2005 4:22 am
Posts: 24
I know i can do it that way. but there is a peace of code that i cannot change and they have used a vector instead of list. so is there any way of mapping vector by hibernate.
If i cannot do it by hibernate then comes the question, can i use hibernate and jdbc together or is there any drawbacks of using them together. because if there is no way of mapping vector by hibernate i have to use jdbc for this part of the project.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 3:30 am 
Newbie

Joined: Mon Jun 06, 2005 8:21 am
Posts: 13
Maybe you could instead use the List mapping and create some kind of Vector to List converter.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.