In my persistence.xml I enabled the data cache: <property name="openjpa.DataCache" value="true(CacheSize=10000)" />
I used a named query "SELECT p FROM Parent p LEFT JOIN FETCH p.children" to load the childrens' list eagerly which is configured lazy in the Parent entity. The Parent entity then was requested from a remote client. The first time the query was executed the client received the parent with the list of children. In the trace I could see OpenJPA executing a SELECT from the database. The second time the query was executed the client received the parent but the list of children was null (and stayed null for all subsequent requests). There was no SELECT fired anymore. openjpa.jdbc.JDBC: Trace: Initial connection autoCommit: true, holdability: 1, TransactionIsolation: 2 openjpa.jdbc.JDBC: Trace: <t 1391284973, conn 2070182756> [0 ms] close openjpa.jdbc.JDBC: Trace: <t 1391284973, conn 711993968> [0 ms] close openjpa.Query: Trace: Executing query: SELECT p FROM Parent p LEFT JOIN FETCH p.childrenList openjpa.jdbc.SQL: Trace: <t 1391284973, conn 2114092546> executing prepstmnt 54657858 SELECT [lots of attributes] FROM PARENT t0, LINIE t1 WHERE t0.ID = t1.PARENT_ID(+) openjpa.jdbc.SQL: Trace: <t 1391284973, conn 2114092546> [187 ms] spent openjpa.jdbc.JDBC: Trace: <t 1391284973, conn 2114092546> [15 ms] close openjpa.Query: Trace: Executing query: SELECT p FROM Parent p LEFT JOIN FETCH p.childrenList openjpa.Query: Trace: Executing query: SELECT p FROM Parent p LEFT JOIN FETCH p.childrenList This "behaviour" went away as soon as I removed the data cache property from the persistence.xml. Is this a bug in the data cache? Seems like it "forgets" to fill the list after the first request. OpenJPA 1.2.3 is used. -- View this message in context: http://openjpa.208410.n2.nabble.com/Join-fetch-does-not-work-if-data-cache-is-enabled-tp6787245p6787245.html Sent from the OpenJPA Users mailing list archive at Nabble.com.