-->
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: Mapping suggestion
PostPosted: Wed Oct 13, 2004 11:04 am 
Newbie

Joined: Thu Oct 09, 2003 7:15 pm
Posts: 11
Location: London, UK
Hello,

I was wondering if I could have a suggestion regarding this issue of mine.
I have a "partner"object that has a 1-2-1 association to (several) summary table that track its hits.
When I use an hibernate one-to-one association, I get the (obvious) desired behavior.
However, more often than not I'm only listing "partner" objects and not acessing their associated objects.
Since for performance reasons there are many summary tables (tracking monthly hits, weekly hits, etc...),
I'd rather ONLY hydrate those objects when I so want, ie, I'd like to specify the one-to-one relationship as
somewhat "lazy".
Can I ask for a one-to-one relationship to be hydrated on-demand?
What is the best way to achieve this? What is the recommended approach?
If I replace the one-to-one relationship with a many-to-one, I have to perform the cascading deletes for all the
associations at the controller level.

I don't think a one-to-many relationship is the way to go because there aren't foreign keys to the associated
summary tables on the partner table.


Below is a snippet of the partner class:

<class name="net.jordan.opm.Partner" table="partner">
<cache usage="read-write" />
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="creationDate" column="creation_date"/>
<property name="lastModifiedDate" column="last_modified_date"/>
<property name="active" type="boolean"/>
<property name="visible" type="boolean"/>
<property name="username"/>
<property name="password"/>
<component name="office" class="net.jordan.opm.Office">
<property name="URL" column="url"/>
<component name="contact" class="net.jordan.opm.Contact">
<property name="name" column="partner_name"/>
<property name="phone" column="phone1"/>
<property name="mobile" column="mobile_phone1"/>
<property name="fax" column="fax1"/>
<property name="email" column="email1"/>
</component>
<component name="address" class="net.jordan.opm.Address">
<property name="street1" column="street"/>
<property name="city"/>
<property name="location"/>
<property name="country"/>
<property name="state" column="state_province"/>
<property name="postcode" column="postcode"/>
</component>
</component>
<one-to-one name="partnerHit" class="net.jordan.opm.PartnerHit" cascade="delete" property-ref="partner" />
</class>


And below is a snippet of one of the summary tables:

<class name="net.jordan.opm.PartnerHit" table="partner_hit">
<!--cache usage="read-write"/-->
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="hits"/>
<many-to-one name="partner" class="net.jordan.opm.Partner" column="fk_partner_id" cascade="none"/>
</class>

Hibernate version: 2.1.6

Mapping documents:

Name and version of the database you are using: MySQL4



Thanks
jorge


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.