-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate 3 table mapping, all getters/setters in 1 object.
PostPosted: Tue Jan 17, 2006 12:52 pm 
Newbie

Joined: Tue Jan 10, 2006 10:59 pm
Posts: 1
Hi All,

I am new to hibernate,

using hibernate 3.0 in oracle.


I have three tables company, company_address and address table.

Company and Address are related thru company_address table.

the company_address table has three fields
1.address_id 2.address_type_id -->primary keys
3.company_id.

address_id from address table, company_id from company table.

I have three objects (company,companyaddress,address).

company and address need to be populated before populating company_address table.


I created this mapping, please verify this is correct.

<hibernate-mapping>
<!-- This mapping inserts, updates, deletes rows into COMPANY and
table -->
<class name="com.myproj.wsobjects.Company" table="COMPANY">
<id name="id" unsaved-value="null"
column="ID">
<generator class="sequence">
<param name="sequence">SEQ_COMPANY</param>
</generator>
</id>
<property name="name" column="NAME" />
<property name="statusId" column="COMPANY_STATUS_ID" />
<property name="countryCode" column="COUNTRY_CODE" />

<property name="industry_id" column="INDUSTRY_ID" />
<property name="revenue_group_id" column="REVENUE_GROUP_ID" />
<property name="company_size_id" column="COMPANY_SIZE_ID" />

<property name="company_type_id" column="COMPANY_TYPE_ID" />



</class>



<!-- added new company_address table mapping -->

<class name="com.myproj.wsobjects.CompanyAddress" table="COMPANY_ADDRESS">
<composite-id>
<key-property name="address_id" column="ADDRESS_ID" />
<key-property name="address_type_id" column="ADDRESS_TYPE_ID" />
</composite-id>

<many-to-one name="company" column="COMPANY_ID" not-null="true"></many-to-one>
<many-to-one name="address" column="ADDRESS_ID" not-null="true"></many-to-one>

</class>

<!-- added new address table mapping -->
<class name="com.myproj.wsobjects.Address" table="ADDRESS">
<id name="id" unsaved-value="null"
column="ID">
<generator class="sequence">
<param name="sequence">SEQ_ADDRESS</param>
</generator>
</id>
<property name="address1" column="ADDRESS1" type="java.lang.String" />
<property name="address2" column="ADDRESS2" type="java.lang.String" />
<property name="city" column="CITY" type="java.lang.String" />
<property name="postalCode" column="POSTAL_CODE" type="java.lang.String" />
<property name="state_prov_id" column="STATE_PROV_ID" />
</class>
</hibernate-mapping>



I am using the company object everywhere (for add, delete,save etc).

Where will i add the getters and setters for company_address and address table.


I want to use a single object which will populate all these fields in my code.


How to achieve this.


Thanks a lot for all your inputs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.