Hi

A while back, I tweaked Hibernate in order to get it to replicate XML
elements properly when an element is referring to another element in the
same XML structure. As the code was/is, it only checks for existence in
the database, not in the session cache, making it impossible to
replicate such elements in a single transaction.

Example:

    <ServiceLineCategory>
        <categoryId>1000051</categoryId>
        <categoryName>PDI</categoryName>
        <description>SBR:Delivery Data</description>
        <serviceLineDatasources>
            <ServiceLineDatasource>
                <datasourceId>1000051</datasourceId>
                <serviceLineCategory>1000051</serviceLineCategory> <!--
Refers to categoryId above in structure. Need to look it up in the
session cache by key. *>
                <datasourceType>0</datasourceType>
            </ServiceLineDatasource>
        </serviceLineDatasources>
        <serviceLineRuleTemplates/>
    </ServiceLineCategory>



When I updated and merged my code, it turns out that the method in
StatefulPersistenceContext I used to check for existence in the session
cache, is no longer returning the referred element, even though it is
present in the entityEntries map.

This is the code snipped I added in DefaultReplicateEventListener:

// is there a copy of the object in the session cache already? 
EntityKey key = new EntityKey(id, persister,
event.getSession().getEntityMode());
oldVersion =
event.getSession().getPersistenceContext().getEntity(key);

So, this brings me to the question of the relationship between
entityEntries and entitiesByKey fields in StatefulPersistenceContext. It
seems to me that the nomenclature suggests that these are all supposed
to contain the same entities at all times, mapped by different keys. The
implementation suggests this as well, but addEntry(...) breaks this by
not adding to entitiesByKey. It seems to me that when addEntry(...) is
used, it is not possible to look up an entity in the cache by key ??

Any comments on this would be appreciated.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to