Hi,
I'm quite new to Hibernate and am trying to modify my existing web apps' persistence layer to use it..
I have two database tables:
Code:
Portal (Portal_id, name, url, etc.)
Portal_Zipcode_Map (portal_id, zipcode)
There is no separate zipcode table, nor a zipcode_id field in Portal_zipcode_map....
Portal.java contains a
Code:
List postCodes
along with other properties.
PortalZipcodeMap.java has only:
Code:
Integer portalId
String zipcode
Both classes have their default constructors...
In Portal.hbm.xml I have defined the 'bag' as follows:
Code:
<bag
name="postCodes"
table="portal_zipcode_map"
lazy="false"
inverse="true"
cascade="none"
>
<key column="portal_id"/>
<many-to-many class=".PortalPostcodeMap"
column="postcode"
outer-join="false"/>
</bag>
And this works...But I'm not confident that this is the best approach..
Do I have to represent the portal_postcode_map as a java class in order to populate the
Code:
postCodes
list of the
Code:
Portal
object?
Can't I simply load the postcodes as simple String values?
Thanks in advance.
Cagan
[/b]