-->
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.  [ 7 posts ] 
Author Message
 Post subject: [Struts] get list of companies and save user
PostPosted: Thu May 06, 2004 5:55 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
I'm currently working on a user management system with struts, hibernate and mysql.

I'm new to Hibernate, but what I want to do is the following:

When the administrator is creating a user, he has to select the company of the user from a combobox in the userform.

I've two tables: useraccount and company

So, the user has to be saved with the proper companyID.

I've this code in my createUser.jsp:
Code:
<html:select property="company" size="1">
  <html:option key="users.noselection" value=""/>
  <html:optionsCollection property="companyID" value="companyID" label="companyName"/>
</html:select>

But no combobox or list is seen...

I've got a CompanyBean, with all accessor methods of the company-table. And in the UserAccountBean, I've an getCompany, setCompany method.

I've got this code in my UserAccount.hbm.xml


Code:
    <set name="company" table="COMPANY">
        <key column="companyID"/>
        <many-to-one name="company"
                     class="Company"
                     column="companyID"/>
    </set>


In my Company.hbm.xml, I've the properties of the CompanyBean.


So, How could I list all the company's in a combobox? And when I've one selected, save the companyID in my UserAccount table????

Thanks for all your help!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 6:02 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
nobody?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 6:24 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
<set lazy="false" name="company" table="COMPANY">
<key column="companyID"/>
<many-to-one name="company"
class="Company"
column="companyID"/>
</set>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 6:25 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
oh, forget previous repsonse, your mapping file is wrong

you cannot have a many to one inside a collection, it has non sense, read the doc again


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 08, 2004 10:18 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
So, how should I do this dan?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2004 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
one-to-many, but read the doc as Antony said, this is important.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 6:30 am 
Beginner
Beginner

Joined: Thu May 06, 2004 5:30 am
Posts: 45
So, is this mapping right?

Code:
<many-to-one name="companyID" />
    <set name="companyID">
        <key column="companyID" />
        <one-to-many class="Company" />
    </set>


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