[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.rt.eclipselink] Re: Cache issue
|
Thank you James for your reply.
My save method is the following (for new object):
@Override
public final void save(final T object) {
//Get the entity Manager
EntityManager entityManager = JpaManager.getManager();
try {
entityManager.getTransaction().begin();
entityManager.persist(object);
entityManager.getTransaction().commit();
}catch(Exception ex){
//Back to the previous status
entityManager.getTransaction().rollback();
}
finally {
JpaManager.closeManager(entityManager);
}
}
the edit method (to update entity) is:
@Override
public final void edt(T object) {
//Get the entity Manager
EntityManager entityManager = JpaManager.getManager();
try {
entityManager.getTransaction().begin();
object = entityManager.merge(object);
entityManager.getTransaction().commit();
}catch(Exception ex){
//Back to the previous status
entityManager.getTransaction().rollback();
}
finally {
JpaManager.closeManager(entityManager);
}
}
As you can see I use persist() for new object and merge() for existing
object.
Have you an explanation about the fact my code seems to work when I set
the cachen type to None?From documentation:
"NONE â This option does not preserve object identity and does not cache
objects. Oracle does not recommend using this option."
Is this not to disable the cache?
For "eclipselink.cache.shared.default":
"The default for whether or not the EclipseLink session cache is shared
by multiple client sessions."
Why is this to disable the cache?What it is mean with client sessions?I
crete and close my entity manager using the "method way", that is every
time I call a persist, merge etc... function.
BR,
Enrico
James ha scritto:
That is odd, the cache should always be up to date. It could be an
issue with you save() method. It use persist() which in JPA is only
valid for saving new objects, if it is an existing object then you must
use merge().
To disable to cache do not set the type to none, instead use,
"eclipselink.cache.shared.default"="false"