-->
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: Adding to Map of immutable members without loading the set?
PostPosted: Tue Sep 01, 2009 3:54 am 
Newbie

Joined: Sun Aug 16, 2009 8:36 am
Posts: 7
Hello All,

I have some problems getting hibernate to behave as I require. Hope you can help.

I have a simple class that manages a set of 'versioned' types (in this example BLOBS, but, relational objects must also be supported). In some cases we want to return all versions of the referenced data (an audit), but, in 99.9% of the cases (processing runtime) we only need the latest version of the underlying object. It is important to get only the latest version as in our domain there are many large/complex previous revisions.

We have a simple filter to allow us to extract only the latest revision. The problem is that many domain operations result in a new revision of the current object.

If the filter is not used everything works fine (but we pull back all previous revisions unnecessarily), if the filter is used, when we persist the 'VersionedComponent' we (obviously) loose all the previous revisions.

We in fact only want to assert the new version that was created from the current one (and not alter the originals).

We have tried marking the objects as 'mutable=false' (as they are immutable' but this still does not result in the required update. We cannot use inverse='true' and manage the persisted from the child end as some of the versioned components arenot in our domain model.


The details of our mapping is blow. I hope someone can help us solve this issue.

Thanks for your time!


Ori


PS: I have read the FAQ entry regarding the need to load an entire collection before altering elements, however, surely this is not the case for an immutable example like the one presented above?


Code:
<class name="com.domain.VersionedComponent"
   table="versioned_components"
   mutable="false"
   >

       ....

       <map name="componentVersions" sort="natural" cascade="save-update" table="component_versions mutable="false"">
            <key column="component_id_fk"/>
            <composite-map-key class="com.domain.Version">
               <key-property name="revision" column="revision"/>
               <key-property name="isHeadRevision" column="isHeadRevision"/>
            </composite-map-key>
         <element column="versioned_component">
            <type name="com.dao.hibernate.types.ComponentBlobType"/>
         </element>
            <filter name="HeadRevisionOnlyFilter" condition="isHeadRevision='true'"/>
        </map>

       ....

</class>




Hibernate v3.2
Postgres 8.0


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.