Dear Colleagues,
We are using Hibernate successfully in production for a year now. Thank you for the good job.
In production (Hibernate-Version: 3.1) we get the error below. In our case some table records can be deleted. A batch process deletes those records by executing native sql using a jdbc connection returned by calling session.connection ().
When a query is executed against the same table we get the following error, althouh no cache configuration is in place.
Quote:
Mon Apr 16 08:33:07 MEST 2007: <E> <org.hibernate.event.def.AbstractFlushingEventListener.:-1> <0> Could not synchronize database state with session <> org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:27)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2204)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:951)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1485)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)
Cache properties such as "hibernate.cache.use_second_level_cache", "hibernate.cache.provider_class"and "hibernate.cache.use_query_cache" are not set.
The documentation states that the second level cache is enabled by default for classes which specify a <cache> mapping. In our case the is no <cache> element in any mapping file at all.
I searched the documentation and the forums and only found instructions about how to enable or disable the cache.
CacheMode.REFRESH and setCasheable(false) did not help either (actually tries with hibernate 3.2 in another application in the development environment that has a similar problem.)
Can you please help me with tips?
Thanke in advance and best regards.
Walid
------------------------------------
Following is the "hibernate.cfg.xml"
------------------------------------
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- local connection properties -->
<!-- datasource connection properties -->
<property name="connection.datasource">NameOfDataSource</property>
<!-- dialect for Sybase -->
<property name="dialect">
org.hibernate.dialect.SybaseDialect
</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.connection.autocommit">false</property>
<mapping resource="Smsgrp.hbm.xml" />
.
.
.
</session-factory>
</hibernate-configuration>
------------------------------------
and the mapping file.
------------------------------------
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="de.my_package.name">
<class name="SMSMonitoring" table="smsmon">
<id
column="mon_id"
name="id"
type="integer"
>
<generator class="identity" />
</id>
<property
column="mon_type"
length="10"
name="monType"
not-null="false"
type="integer"
/>
<property
column="mon_triggered"
length="23"
name="monTriggered"
not-null="false"
type="timestamp"
/>
<property
column="mon_scanned"
length="23"
name="monScanned"
not-null="false"
type="timestamp"
/>
<property
column="mon_msisdn"
length="19"
name="monMsisdn"
not-null="false"
type="string"
/>
<property
column="mon_state"
length="10"
name="monState"
not-null="false"
type="integer"
/>
<property
column="mon_notified"
length="23"
name="monNotified"
not-null="false"
type="timestamp"
/>
<property
column="mon_vfstatus"
length="10"
name="monVfstatus"
not-null="false"
type="integer"
/>
<property
column="mon_transact"
length="10"
name="monTransact"
not-null="false"
type="integer"
/>
</class>
</hibernate-mapping>