-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Refresh object - incident
PostPosted: Thu Oct 28, 2010 8:35 am 
Newbie

Joined: Thu Oct 28, 2010 8:15 am
Posts: 4
Hi all,

I have developed some applications with Hibernate and today I have an incident that I didn't resolve yet.

The incident is:

If I update some object (update/merger method and commit transaction) and execute some query (begin transaction / criteria.list) this object appear with old data in my list. If firstly I refresh my UI (Web app) the object appear with data has been updated, secondly I refresh again the object appear with old data. But it not occur in all moments, in same cases I need restart app.

Can somebody help me? I tried many actions but nothing run.

Thanks a lot.


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Fri Oct 29, 2010 5:37 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
You need to give more details.


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Fri Oct 29, 2010 1:27 pm 
Newbie

Joined: Thu Oct 28, 2010 8:15 am
Posts: 4
Hi,

Follow more details:

# Hibernate configuration

<property name="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.default_schema">ASSI</property>
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">utf-8</property>


# Server start up log

INFO: Configured SessionFactory: null
INFO: Hibernate Validator not found: ignoring
INFO: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
INFO: Using Hibernate built-in connection pool (not for production use!)
INFO: Hibernate connection pool size: 20
INFO: autocommit mode: false
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
INFO: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO: Automatic flush during beforeCompletion(): disabled
INFO: Automatic session close at end of transaction: disabled
INFO: Scrollable result sets: enabled
INFO: JDBC3 getGeneratedKeys(): disabled
INFO: Connection release mode: auto
INFO: Default schema: ASSI
INFO: Default batch fetch size: 1
INFO: Order SQL updates by primary key: disabled
INFO: Order SQL inserts for batching: disabled
INFO: Using ASTQueryTranslatorFactory
INFO: Query language substitutions: {}
INFO: Second-level cache: enabled
INFO: Query cache: disabled
INFO: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
INFO: Optimize cache for minimal puts: disabled
INFO: Structured second-level cache entries: disabled
INFO: Statistics: disabled
INFO: Deleted entity synthetic identifier rollback: disabled
INFO: Check Nullability in Core (should be disabled when Bean Validation is on): enabled
INFO: building session factory
INFO: Not binding factory to JNDI, no JNDI name configured
AVISO: Settings: Could not parse struts.locale setting, substituting default VM locale



# Business process

The problem occur with all objects that I execute the process below:

In this case the object name is CapacityPlan


Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(SystemPermission)

## Loading object that problem occur

Begin: this.session.getCurrentSession().beginTransaction()

Load object: this.session.getCurrentSession().load(CapacityPlan,2)

## I put this method, but it not resolved

Refresh: this.session.getCurrentSession().refresh(CapacityPlan)

Query: Criteria criteria = this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query = this.session.getCurrentSession().createCriteria(OrganizationUnit)

begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(SystemMenu)

Query: this.session.getCurrentSession().createCriteria(SystemModule)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(SystemPermission)

Begin: this.session.getCurrentSession().beginTransaction()

## Loading object CapacityPlan that the problem occur

Load: this.session.getCurrentSession().load(CapacityPlan,2)

Query: this.session.getCurrentSession().createCriteria(ResoDemandPerson)

## Update object Capacity Plan that the problem occur

update: this.session.getCurrentSession().merge(CapacityPlan)

Commit: this.session.getCurrentSession().getTransaction().commit()

Begin: this.session.getCurrentSession().beginTransaction()

## Loading object Capacity Plan that the problem occur

Load: this.session.getCurrentSession().load(CapacityPlan,2)

Begin: this.session.getCurrentSession().beginTransaction()

Query this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query this.session.getCurrentSession().createCriteria(SystemPermission)

Begin: this.session.getCurrentSession().beginTransaction()

## Query where the object CapacityPlan apper with old data

Query this.session.getCurrentSession().createCriteria(CapacityPlan)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(OrganizationUnit)

Begin: this.session.getCurrentSession().beginTransaction()

Query: this.session.getCurrentSession().createCriteria(SystemMenu)

Query: this.session.getCurrentSession().createCriteria(SystemModule)


Thansk for you help


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Thu Nov 04, 2010 6:57 pm 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Do you commit your transactions?


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Fri Nov 05, 2010 7:24 am 
Newbie

Joined: Thu Oct 28, 2010 8:15 am
Posts: 4
Hi,

Yep, I commit my transactions. In database the data is updated. If I execute load and refresh in this object after update, the incident not occur, but it is a work around.

tks


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Fri Nov 05, 2010 11:17 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
No, this is not workaround. This is how you fetch objects from the database. They are not magically connected to the database if you change them in other transaction.


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Fri Nov 05, 2010 3:21 pm 
Newbie

Joined: Thu Oct 28, 2010 8:15 am
Posts: 4
But, if I exec update some example below:

beginTransaction();

update(object1);
update(object2);
update(object3);

commit();

After this we need execute

load(object1);
refresh(object1);
load(object2);
refresh(object2);
load(object3);
refresh(object3);

Exist other way to refresh this object, for example: refresh all changed objects?

tks a lot.


Top
 Profile  
 
 Post subject: Re: Refresh object - incident
PostPosted: Sat Nov 06, 2010 12:25 pm 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Please post a code. I understand nothing from your words :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.