openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: no state snapshot available on embedded mapping
Date Mon, 14 Jul 2008 16:43:37 GMT

Hi,
  I am not familiar enough with runtime enhancement, so please accept my
explanation with certain degree of disbelief.

   OpenJPA tracks the dirty fields of managed instances and traditional
(i.e. build-time) enhancement ensures that at bytecode level on field
mutators. Runtime enhancement is also able to track dirty fields
when
    a) Java 6 is the runtime
    b) Java 5 and entity using property access and are loaded from database
(not for new instances)

   In Java 5, the entities with field access are not tracked and hence
during commit session, OpenJPA resorts to state comparison for such cases. 
    This checking is skipped on certain cases, as described below: 
    private boolean needsDirtyCheck() {
        if (isIntercepting())
            return false;
        if (isDeleted())
            return false;
        if (isNew() && !isFlushed())
            return false;
+        if (!isTransactional())
+            return false;
        return true;
    }

    Including non-transactional entities to skip dirty check resolves the
issue you have encountered. Exclusion of nontransactional entities form
dirty checking sounds logical to me but due to my limited understanding of
runtime enhancement I am not able to confirm.

 
     * <p>Fields are tracked for all classes that are run through the
OpenJPA
     * enhancer prior to or during deployment, and all classes (enhanced or
     * unenhanced) in a Java 6 environment or newer.</p>
     *
     * <p>In a Java 5 VM or older:
     * <br>- instances of unenhanced classes that use
     * property access and obey the property access limitations are tracked
     * when the instances are loaded from the database by OpenJPA, and are
     * not tracked when the instances are created by application code.
     * <br>- instances of unenhanced classes that use field access are
     * never tracked.</p>

  Change tracking of classes  

Marc Logemann-3 wrote:
> 
> Hi,
> 
> yes, i am using a spring-tomcat-weaver.jar in Tomcat6 (with Java5) to  
> achieve JPA runtime enhancement via Spring.
> 
> What do you mean with workaround? Should this work "normally" ? I was  
> quite happy with runtime enhancement, would be sad to leave that  
> path....
> 
> thx for infos....
> 
> --
> Marc Logemann
> blog http://logemannreloaded.blogspot.com
> privat http://www.logemann.org
> 
> 
> 
> Am 14.07.2008 um 16:22 schrieb Pinaki Poddar:
> 
>>
>> Hi,
>>   Are you using runtime enhancement with Java 5?
>>   If yes, the immediate workaround is to enhance the persistent  
>> classes at
>> build-time.
>>
>> -- 
>> View this message in context:
>> http://n2.nabble.com/no-state-snapshot-available-on-embedded-mapping-tp526616p527331.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/no-state-snapshot-available-on-embedded-mapping-tp526616p527542.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message