-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate second level cache and ora_rowscn
PostPosted: Sat Apr 11, 2009 12:55 pm 
Newbie

Joined: Sat Apr 11, 2009 12:35 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
We are using Spring 2.5.6 with JPA Hibernate Entity Manager 3.3.2 running on Tomcat 6, we are not using OC4J.
We are using Atomikos 2.1.7 for our transaction manager, and here are some of our hibernate settings:

jpa.hibernate.max_fetch_depth=2
jpa.hibernate.default_batch_fetch_size=16
jpa.hibernate.order_updates=true
jpa.hibernate.connection.isolation=4
jpa.hibernate.generate_statistics=true
jpa.hibernate.jdbc.use_get_generated_keys=false
jpa.hibernate.jdbc.fetch_size=0
jpa.hibernate.jdbc.batch_size=30
jpa.hibernate.connection.release_mode=after_statement
jpa.hibernate.default_schema=
jpa.hibernate.strict_jpaql=true
jpa.hibernate.cache.use_second_level_cache=true
jpa.hibernate.cache.use_query_cache=true

Mapping documents:
I set up the version in the domain object as:

@Version
@Column(name = "ORA_ROWSCN", insertable = false, updatable = false)
@org.hibernate.annotations.Generated(GenerationTime.ALWAYS)
private Long version;

This would pick up the ora rowscn id properly on select. But when trying to do the update back, it would increment the ora rowscn id by 1 and would trigger the StaleObjectException.

Example logs. You can see on select it retrieves the proper value '137513970' but on update, Hibernate increments the value by 1 to '137513971' . I couldn't figure out a way to stop Hibernate from incrementing this value.

10:36:26,938 INFO BusMasterBean: loading bus for edit for =184 or state=0
Hibernate:
/* named HQL query apvBusForBusId */ select
apvbusines0_.APV_BUS_ID as APV1_75_,
apvbusines0_.ORA_ROWSCN as ORA18_75_,
from
APV_BUSINESS_UNIT_SUBDIVISION apvbusines0_
where
apvbusines0_.BUS_ID=?
10:36:27,031 TRACE LongType: returning '137513970' as column: ORA18_75_

Then in the update:

Hibernate:
/* update
org.lds.cubs.common.domain.ApvBusinessUnitSubdivision */ update
APV_BUSINESS_UNIT_SUBDIVISION
set
CREATED_BY=?,
CREATED_DATE=?,
UPDATED_BY=?,
UPDATED_DATE=?,
BUS_ID_CODE=?,
BUS_NAME=?,
BUS_STATUS_LKP_ID=?,
BUS_STATUS_LKPT_ID=?,
CFIS_BUSINESS_UNIT=?,
CORPORATE_ID=?,
DAYS_TO_DORMANCY=?,
DEFAULT_BUS_CATEGORY_GROUP_ID=?,
DEFAULT_DIK_REALLOC_CAT_GRP_ID=?,
DFLT_STOP_PAYMENT_EXPIRY_DAYS=?,
DON_ADJ_PREDEF_MONETARY_LIMIT=?,
FISCAL_EDITING_ALLOWED_DAYS=?,
CURRENCY_CODE=?,
COUNTRY_GEOPOL_LOCATION_CODE=?,
CAO_ORG_ID=?,
TAX_ID=?,
TAX_YEAR_START=?,
TAXING_AUTHORITY_ADDRESS=?,
TRANSACTION_RETENTION_YEARS=?,
APPROVAL_STATUS_LKP_ID=?,
APPROVAL_STATUS_LKPT_ID=?,
BUS_ID=?,
REASON_FOR_REJECTION=?,
RECORD_UPDATED_FLAG=?,
REJECTED_DATE=?,
UPDATER_COMMENT=?
where
APV_BUS_ID=?
and ORA_ROWSCN=?
10:38:10,016 TRACE StringType: binding 'cubstest1' to parameter: 1
10:38:10,016 TRACE TimestampType: binding '2009-03-13 10:35:58' to parameter: 2
10:38:10,016 TRACE StringType: binding 'unsoktchoi' to parameter: 3
10:38:10,016 TRACE TimestampType: binding '2009-03-13 10:38:09' to parameter: 4
10:38:10,016 TRACE StringType: binding 'TTTTTT' to parameter: 5
10:38:10,016 TRACE StringType: binding 'T Bus' to parameter: 6
10:38:10,016 TRACE LongType: binding '21' to parameter: 7
10:38:10,016 TRACE LongType: binding '10' to parameter: 8
10:38:10,016 TRACE StringType: binding 'TTTTTTT' to parameter: 9
10:38:10,016 TRACE StringType: binding 'T1' to parameter: 10
10:38:10,016 TRACE ShortType: binding '34' to parameter: 11
10:38:10,016 TRACE IntegerType: binding '331' to parameter: 12
10:38:10,016 TRACE IntegerType: binding null to parameter: 13
10:38:10,016 TRACE ShortType: binding '34' to parameter: 14
10:38:10,016 TRACE BigDecimalType: binding '12000' to parameter: 15
10:38:10,016 TRACE ShortType: binding '12' to parameter: 16
10:38:10,016 TRACE LongType: binding '1' to parameter: 17
10:38:10,016 TRACE LongType: binding '251' to parameter: 18
10:38:10,016 TRACE LongType: binding '4005739' to parameter: 19
10:38:10,016 TRACE StringType: binding 'T2' to parameter: 20
10:38:10,016 TRACE StringType: binding '26 Feb' to parameter: 21
10:38:10,016 TRACE StringType: binding '123 Main St
San Jose, CA' to parameter: 22
10:38:10,016 TRACE ByteType: binding '12' to parameter: 23
10:38:10,016 TRACE LongType: binding '3' to parameter: 24
10:38:10,016 TRACE LongType: binding '46' to parameter: 25
10:38:10,016 TRACE LongType: binding '184' to parameter: 26
10:38:10,016 TRACE StringType: binding null to parameter: 27
10:38:10,016 TRACE StringType: binding 'Y' to parameter: 28
10:38:10,016 TRACE TimestampType: binding null to parameter: 29
10:38:10,016 TRACE StringType: binding null to parameter: 30
10:38:10,016 TRACE LongType: binding '36' to parameter: 31
10:38:10,016 TRACE LongType: binding '137513971' to parameter: 32

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 10.2.0.4
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?
We are trying to implement optimistic locking through the used of ORA_ROWSCN, and the developers are running into the problem that hibernate is incrementing the ora_rowscn number when updates are done on the row.
Develpers don't see a way to make using ORA_ROWSCN work with the second-level cache. If they could tell Hibernate to invalidate the cache when updates are done instead of put the updated entity directly into the cache, they think they could make it work. Unfortunately they haven't been able to find a way to modify the cache's behavior.

Has anybody run into this problem?
I will appreciate any suggestions on how to make hibernate to work with ora_rowscn when second level cache is used in hibernate.


Read this: http://hibernate.org/42.html


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

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.