don't get latest data from database [message #1286961] |
Mon, 07 April 2014 04:30  |
Eclipse User |
|
|
|
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="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
<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"/>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="far"/>
<property name="jpaPropertyMap">
<props>
<prop key="eclipselink.weaving">false</prop>
</props>
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver">
</bean>
</property>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="false"/>
<property name="generateDdl" value="false"/>
<property name="database" value="ORACLE"/>
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
</bean>
Harald
|
|
|
Re: don't get latest data from database [message #1290930 is a reply to message #1286961] |
Thu, 10 April 2014 11:12  |
Eclipse User |
|
|
|
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.06091 seconds