-->
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.  [ 5 posts ] 
Author Message
 Post subject: 2nd level cache loading problem with <joined-subclass use
PostPosted: Mon Jun 21, 2004 9:04 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Hi,

I'm using ehcache as second level cache.
My problem appears when loading object defined with <joined-subclass mapping

for instance:
Code:
<hibernate-mapping>
    <class name="org.xx.dossierformation.model.DossierFormation" table="DOSSIER_FORMATION" lazy="true">
        <cache usage="read-write"/>

        <id name="id" column="DOSSIER_FORMATION_ID" type="java.lang.Long">
            <generator class="identity"/>
        </id>

        <property name="dossierFormationType" column="DOSSIER_FORMATION_TYPE" type="java.lang.String" not-null="true"/>

        <joined-subclass name="org.xx.dossierformation.model.DossierFormationStd" table="DOSSIER_FORMATION_STD" lazy="true">
            <key column="DOSSIER_FORMATION_STD_ID_FK"/>
            <property name="dossierFormationStdTypeAccordEngagement" column="DOSSIER_FORMATION_STD_TYPE_ACCORD_ENGAGEMENT" type="java.lang.String" not-null="true"/>

        </joined-subclass>

        <joined-subclass name="org.xx.dossierformation.model.DossierFormationMasse" table="DOSSIER_FORMATION_MASSE" lazy="true">
            <key column="DOSSIER_FORMATION_MASSE_ID_FK"/>
            <property name="dossierFormationMasseDureeBaremeJours" column="DOSSIER_FORMATION_MASSE_DUREE_BAREME_JOURS" type="java.lang.Float"/>
        </joined-subclass>

    </class>

</hibernate-mapping>


In my design this DossierFormation object doesn't exist on its own. It's either a DossierFormationStd or a DossierFormationMasse.
And it works as expected.

Unless you load a DossierFormation, don't update it, and reload it. Then the cache gives you a DossierFormation object that is not an instance of any of the joined-subclass.

Concretly it happens if a user loads an object for modification, then changes his mind, do something else, and finally wants to modify this same object.
If the update is not commited, then the second level cache doesn't know it has to refresh the object and loads the main object and not the joined-subclass one. As a consequence you can't test it with "instanceof" and have to reload the desired object and specify its real class, not subclass.

Is it an expected behavior or is there any trick to avoid that?

nodje


Last edited by nodje on Tue Jun 03, 2008 5:35 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 9:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I very much doubt that this is true.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 9:23 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Well, you got to trust me, this happens every time we don't do the update() on the loaded object!
We are in a testing phase and we just discovered it since we have been testing our 'Back' button.

I could give you the whole mapping, but it's of no interest. What I gave is enough I believe.
As for reproducing the problem with neutral classes, it's going to take me a good 2 hours and we must deliver at the end of the week. I'm ready to do it tough, if you have no simple way either to reproduce it.

But basically, if you say: whether loaded form the cache or not, a joined-class object cannot be an instance of the superclass only,
Then I say, this is possible, i've just seen it!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 9:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Do you have any idea how many bogus bug reports we see every week?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 10:09 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
I'm pretty sure it's fat figure.

Every time I go on the forum and see the amount of post I'm happy not to be in your shoes. But that's the price to pay for a very successful product I suppose.

Anyway, there exists an alternative for the pb, just make a load on the joined-class and not on the superclass. Even though that's a real pity, it's gonna works.

But it really happens, and our application is more than a yearold. The persistence is working fine, we don't have pb with hibernate anymore. Except this one.

Moreover the pb is not related to ehcache. The pb occurs even if the cache is disabled.

[/img]


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

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.