Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » don't get latest data from database
don't get latest data from database [message #1286961] Mon, 07 April 2014 08:30 Go to next message
Harald Windisch is currently offline Harald Windisch
Messages: 4
Registered: February 2013
Junior Member
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 15:12 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
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();
Previous Topic:XmlAdapter with xml-path
Next Topic:Issue with orphanRemoval = true and OptimisticLockException
Goto Forum:
  


Current Time: Thu Oct 23 03:09:07 GMT 2014

Powered by FUDForum. Page generated in 0.01971 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software