sync error with eclipselink [message #729565] |
Mon, 26 September 2011 10:10  |
Eclipse User |
|
|
|
hi all
i'm facing a GIANT problem here
here's the scneario: we have a RCP app, using google guice to inject dependencies.
we have a view, that lists all our companies. and when double clicked, the view opens a edior, and we can edit this company. ok, everything works perfectly here. until we change the data and DO NOT save.
when we change the company name, and save, everything is ok, but when we change the company name and just close the editor, seems like it changes the entity on the database (but it doesn't) and the entirely session get the wrong object.
we changed the company name from 'asd' to 'asd123', and we do not saved this change. but everytime we get the username (e.g.: 'select e from Empresa e where e.id = :id') eclipselink get the 'asd123' company
is this some 'cache problem' or something?
some details:
when we open the editor we (aparently) reload the entity that was passed via EditorInput
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
EmpresaEditorInput eei = (EmpresaEditorInput) input;
empresaHandler.setEmpresa(empresaHandler.findEmpresa(eei.getEmpresa().getId()));
setSite(site);
setInput(eei);
}
my entitymaneger, with cache disabled
private static void init() {
properties.put(PersistenceUnitProperties.TARGET_DATABASE, TargetDatabase.PostgreSQL);
properties.put(PersistenceUnitProperties.JDBC_DRIVER, Driver.class.getCanonicalName());
properties.put(PersistenceUnitProperties.JDBC_URL,"jdbc:postgresql://127.0.0.1:5432/ecf");
properties.put(PersistenceUnitProperties.JDBC_USER, "postgres");
properties.put(PersistenceUnitProperties.JDBC_PASSWORD, "adminadmin");
properties.put(PersistenceUnitProperties.CONNECTION_POOL_MIN, "5");
properties.put(PersistenceUnitProperties.CONNECTION_POOL_MAX, "10");
properties.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT,"false");
properties.put(PersistenceUnitProperties.CACHE_STATEMENTS,"false");
properties.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");
properties.put(PersistenceUnitProperties.CLASSLOADER, Bootstrap.class.getClassLoader());
// Cria tabelas novas (mas não atualiza)
// properties.put(PersistenceUnitProperties.DDL_GENERATION, "create-tables");
properties.put("eclipselink.logging.level", "FINE");
properties.put("eclipselink.logging.timestamp", "false");
properties.put("eclipselink.logging.session", "false");
properties.put("eclipselink.logging.thread", "false");
properties.put("eclipselink.logging.exceptions", "true");
emf = new PersistenceProvider().createEntityManagerFactory("ecf", properties);
if i set the queryhint to always refresh the cache (when loading a specficif company and load all companies), it works, but i dont want that.
the scope of my repository is no singleton, so everytime I get the repository, is a new one.
any ideas?
thanks in advice
|
|
|
|
Re: sync error with eclipselink [message #729634 is a reply to message #729631] |
Mon, 26 September 2011 12:53  |
Eclipse User |
|
|
|
not sure what part of your question is still open - eclipselink uses caching, you best look this up in the doco.
If you change the object returned by eclipselink you make the cached object dirty.
So you have at least two options - either work on a copy (clone) of the cached object and merge this back when the change is committed or work on the original and refresh if cancelled
hope this helps
W.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03854 seconds