|don't get latest data from database [message #1286961]
||Mon, 07 April 2014 08:30
| Harald Windisch
Registered: February 2013
I am developing a standalone spring application. It is based on a oracle database which is used with eclipselink JPA.|
When the application reads an object from the database, it is correct. The problem comes, when the database is changed from an other program, e.g. SqlDeveloper, SQL-Plus. My program gets only the data as it was before. It looks like the program only takes the Object from the cache and don't look into the database.
If I stop the application, and start it again, it gets the right data.
I tried a lot of options (calling flush, refresh, clear). But it is as it is. My aplication don't see any changes in the database.
Eclipselink weaving is off. I use the spring weaving (SpringLoadTimeWeaver).
Here is my configuraiton ofEntityManagerFactory and TransactionManager:
<tx:annotation-driven transaction-manager = "transactionManager" proxy-target-class="true" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@localhost:1521:far9" />
<property name="username" value="xxxxx"/>
<property name="password" value="xxxxx"/>
<property name="persistenceUnitName" value="far"/>
<property name="showSql" value="false"/>
<property name="generateDdl" value="false"/>
<property name="database" value="ORACLE"/>
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
|Re: don't get latest data from database [message #1290930 is a reply to message #1286961]
||Thu, 10 April 2014 15:12
| Chris Delahunt
Registered: July 2009
When you say you have tried to refresh and clear and don't see any changes, can you show what you have tried? em.refresh(entity) should force a database query to get the data from the database, so either the query isn't happening or the SqlDeveloper transaction isn't visible to the currently active transaction for some reason. Try turning on EclipseLink logging to get more information on what might be happening, and see what is returned from a native SQL query such as em.createNativeQuery("select * from <yourtable>").getResultList();
Powered by FUDForum
. Page generated in 0.01971 seconds