openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boblitz John <John.Bobl...@BERTSCHI.com>
Subject Bug? DataCache after update contains only the updated information from a Collection
Date Thu, 07 Jun 2012 07:05:28 GMT
Hello,
 
I'm running openJpa 2.2.0 and have a problem with the DataCache function. 
I spent the better part of two days localizing the problem and looking for solutions, but
alas ...
 
So, hoping some guru out there can spot my error, here the details:
 
Environment JavaSE 
 
Persistence XML:
<property name="openjpa.DataCache" value="true(CacheSize=5000, EnableStatistics=true)"
/>
<property name="openjpa.RemoteCommitProvider" value="sjvm" /> 
<property name="openjpa.DetachState" value="fetch-groups(DetachedStateField=true)" />
 
Entities:

@MappedSuperclass
@EntityListeners({ EntityManipulationLogger.class, EntityLogger.class })
public abstract class BaseEntity {
@Version
@Column(columnDefinition = "int8")
private long versionId;

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "uniqueid", columnDefinition = "int8")
protected long uniqueId;

...
 
@Entity
@Table(name = "Equipment")
public class Equipment extends BaseEntity {

@JsonManagedReference
@OneToMany(cascade = CascadeType.ALL, mappedBy = "equipmentId")
@InverseLogical("equipmentId")
private Set<Axle> axles = new HashSet<Axle>();

...
 
@Entity
@Table(name = "Axle")
public class Axle extends BaseEntity {

@JsonBackReference
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "equipmentId", columnDefinition = "int8", nullable = false)
private Equipment equipmentId;

 
Code used to Update the DataBase:

@Override
public <T extends BaseEntity> T update(T pEntity) {
    this.lock.lock();
   T object = null;
    try {
         try {
                getTransaction().begin();
                object = merge(pEntity);
        } catch (Exception e) {
                mTrc.error("Error in update(): ", e);
                getTransaction().setRollbackOnly();
                handleException(e);
        } finally {
                if (getTransaction().isActive()) {
                    if (getTransaction().getRollbackOnly()) {
                    getTransaction().rollback();
                } else {
                    getTransaction().commit();
                }
            }
        }
    } catch (Exception e) {
        mTrc.error("Error in update(): ", e);
        handleException(e);
    } finally {
        this.lock.unlock();
    }
    return object;
}

Symptom:
When updating the Equipment entity, if an additional Axle is added to the Set and the other
Axles remain unchanged:
1.  Upon entry into update(), pEntity contains all the Axels (new & old) including UID
& Version.
2.  object = merge(pEntity) - performs as expected, object contains all the Axels and the
new Axel has been assigned a UID
3.  After commit(), the new Axle is added to the Database (good)
4.  The entity is updated in the DataCache (I would assume this is good as well)
5.  "object" however now only contains one element in the Set<Axle> - the one we added,
the others are no longer there.
6.  A subsequent refresh of the returns the same results as in #5! It hits in the DataCache,
so I assume that the Update of the Cache
contains only the "new" data from object.
 
Turning off the DataCache (or excluding the Equipment Entity) solves the problem.
 
Here the complete config:

openjpa.AutoClear: 0
openjpa.AutoDetach: [Ljava.lang.String;@60cf710e
openjpa.BrokerFactory: jdbc
openjpa.BrokerImpl: default
openjpa.CacheDistributionPolicy: default
openjpa.Callbacks: default
openjpa.ClassResolver: default
openjpa.Compatibility: default
openjpa.ConnectionDriverName: org.postgresql.Driver
openjpa.ConnectionFactoryMode: false
openjpa.ConnectionFactoryProperties: QueryTimeOut=5000, PrettyPrint=true, PrettyPrintLineLength=80,
PrintParameters=true
openjpa.ConnectionPassword: ******
openjpa.ConnectionProperties: MaxActive=100, MaxIdle=5, MinIdle=2, MaxWait=60000
openjpa.ConnectionRetainMode: 0
openjpa.ConnectionURL: ******
openjpa.ConnectionUserName: *****
openjpa.DataCache: true(CacheSize=5000, EnableStatistics=true)
openjpa.DataCacheManager: default
openjpa.DataCacheTimeout: -1
openjpa.DetachState: fgs(DetachedStateField=true)
openjpa.DynamicDataStructs: false
openjpa.DynamicEnhancementAgent: true
openjpa.EntityManagerFactory: default
openjpa.FetchBatchSize: -1
openjpa.FetchGroups: [Ljava.lang.String;@53077fc9
openjpa.FlushBeforeQueries: 0
openjpa.Id: g11.persistence
openjpa.IgnoreChanges: false
openjpa.InitializeEagerly: false
openjpa.InstrumentationManager: default
openjpa.InverseManager: true
openjpa.LifecycleEventManager: validating
openjpa.LockManager: mixed
openjpa.Log: log4j
openjpa.ManagedRuntime: auto
openjpa.MaxFetchDepth: -1
openjpa.MetaDataFactory: *** truncated!!
openjpa.MetaDataRepository: default
openjpa.Multithreaded: false
openjpa.NontransactionalRead: true
openjpa.NontransactionalWrite: true
openjpa.Optimistic: true
openjpa.OrphanedKeyAction: log
openjpa.ProxyManager: default
openjpa.QueryCache: true(CacheSize=1000, SoftReferenceSize=100, EvictPolicy='timestamp')
openjpa.QueryCompilationCache: all
openjpa.ReadLockLevel: 10
openjpa.RefreshFromDataCache: false
openjpa.RemoteCommitProvider: sjvm
openjpa.RestoreState: 1
openjpa.RetainState: true
openjpa.RetryClassRegistration: false
openjpa.RuntimeUnenhancedClasses: 1
openjpa.SavepointManager: in-mem
openjpa.Sequence: table
openjpa.TransactionMode: false
openjpa.WriteLockLevel: 20
openjpa.jdbc.DBDictionary: postgres(supportsNullTableForGetImportedKeys=false)
openjpa.jdbc.DriverDataSource: auto
openjpa.jdbc.EagerFetchMode: 2
openjpa.jdbc.FetchDirection: 1000
openjpa.jdbc.FinderCache: true
openjpa.jdbc.IdentifierUtil: default
openjpa.jdbc.LRSSize: 2
openjpa.jdbc.MappingDefaults: jpa
openjpa.jdbc.QuerySQLCache: true(EnableStatistics=true)
openjpa.jdbc.ResultSetType: 1003
openjpa.jdbc.SQLFactory: default
openjpa.jdbc.SchemaFactory: native(ForeignKeys=true)
openjpa.jdbc.Schemas: [Ljava.lang.String;@60cf710e
openjpa.jdbc.SubclassFetchMode: 1
openjpa.jdbc.SynchronizeMappings: null
openjpa.jdbc.TransactionIsolation: -1
openjpa.jdbc.UpdateManager: default
 
 
 
 

 

John

---- 

Who is General Failure, and why is he reading my hard disk?


Mime
View raw message