0
I have a problem with the following query:
SELECT * FROM tipo_calibracao t LEFT OUTER JOIN fator_medio f ON (t.id = f.tipo_calibracao AND f.lote = 42) ORDER BY t.id ASC;
Java:
public List<TipoCalibracao> searchTypes(Long batchId) {
Query query = em.createNativeQuery("SELECT * FROM tipo_calibracao t " +
"LEFT JOIN fator_medio f ON (t.id = f.tipo_calibracao AND f.lote = #batchId) ORDER BY t.id ASC", TipoCalibracao.class);
query.setParameter("batchId", batchId);
return query.getResultList();
}
Running it in mysql it returns what I expect:
'1', 'MO', NULL, NULL, NULL, NULL
'2', 'P', NULL, NULL, NULL, NULL
which would be the normal calibration type table and the null factor medio table, but running the same query in Java it returns an old result for the factor medio table, even if checking by lot, which would be the most current.
I’m using the Eclipselink.
"but running the same query in Java it returns an old result for the table fator_medio, even if checking by lot, which would be the most current." - In other words, this implies that it is some problem of caching or isolation of transactions. Since you didn’t put any code in Java, it’s hard to tell you what’s wrong with it.
– Victor Stafusa
I just put in the Java code. So I figured it might be cache problem, but even though I reset the server it keeps returning an old value.
– Rafael Lima
Where and how you get this
EntityManager
?– Victor Stafusa
I have a Basedao file, then I inherit it from this class.
– Rafael Lima
I believe your
EntityManager
is not being managed properly. How is thisBaseDAO
manages him?– Victor Stafusa