I have read the same problem in this thread but no answer was posted:
http://forum.hibernate.org/viewtopic.php?t=943111
Hibernate version: 3.0.5
Mapping documents:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="foo:/hibernate/SessionFactory">
<!-- SQL dialact -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- DB Connection -->
<property name="connection.username">trvdb</property>
<property name="connection.password">trvdb</property>
<property name="connection.url">jdbc:oracle:thin:@192.168.0.102:1521:ORCL</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<!-- C3P0 Connection Pool -->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.validate">false</property>
<!-- Miscellaneous Settings -->
<!-- Echo all executed SQL to standard output -->
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="dbcp.minIdle">1</property>
<property name="cache.use_query_cache">true</property>
<!-- mapping files -->
<mapping resource="net/dev/fursan/olap/model/pojo/User.hbm.xml"/>
<mapping resource="net/dev/fursan/olap/model/pojo/Form.hbm.xml"/>
<mapping resource="net/dev/fursan/olap/model/pojo/Setting.hbm.xml"/>
<mapping resource="net/dev/fursan/olap/model/pojo/Target.hbm.xml"/>
<mapping resource="net/dev/fursan/olap/model/pojo/Branch.hbm.xml"/>
<mapping resource="net/dev/fursan/olap/model/pojo/Company.hbm.xml"/>
<mapping resource="net/dev/fursan/olap/model/pojo/Customer.hbm.xml"/>
</session-factory>
</hibernate-configuration>
The following is contents of "User.hbm.xml"
Mapping documents:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-cascade="all">
<class name="net.dev.fursan.olap.model.pojo.UserDTO"
table="OLAP_USR"
dynamic-update="true">
<id name="id" column="USR_ID">
<generator class="sequence">
<param name="sequence">OLAP_USR_SEQ</param>
</generator>
</id>
<property name="loginName" column="USR_LGN_NAME"/>
<property name="fullName" column="USR_FULL_NAME"/>
<property name="lastLoginDate" type="timestamp" column="USR_LAST_LGN"/>
<set name="accessedForms"
table="OLAP_FORM_ACCESS"
lazy="true"
cascade="save-update">
<key column="USR_ID"/>
<many-to-many column="FORM_ID"
class="net.dev.fursan.olap.model.pojo.FormDTO"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
UserDTO user = new UserDTO();
user.setLoginName ( username );
user.setFullName ( getFullNameFromLdap( ldap, param, username ) );
user.setLastLoginDate( new Timestamp( new java.util.Date().getTime() ) );
session.save( user );
Full stack trace of any exception that occurs: no exceptionsName and version of the database you are using: Oracle 8.1.6 The generated SQL (show_sql=true):Debug level Hibernate log excerpt:I included both here
Code:
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.SQL - select OLAP_USR_SEQ.nextval from dual
DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
DEBUG org.hibernate.id.SequenceGenerator - Sequence identifier generated: 1
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 1, using strategy: org.hibernate.id.SequenceGenerator
DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [net.dev.fursan.olap.model.pojo.UserDTO#1]
DEBUG org.hibernate.engine.Cascades - processing cascade ACTION_SAVE_UPDATE for: net.dev.fursan.olap.model.pojo.UserDTO
DEBUG org.hibernate.engine.Cascades - done processing cascade ACTION_SAVE_UPDATE for: net.dev.fursan.olap.model.pojo.UserDTO
DEBUG org.hibernate.event.def.WrapVisitor - Wrapped collection in role: net.dev.fursan.olap.model.pojo.UserDTO.accessedForms
DEBUG org.hibernate.engine.Cascades - processing cascade ACTION_SAVE_UPDATE for: net.dev.fursan.olap.model.pojo.UserDTO
DEBUG org.hibernate.engine.Cascades - cascade ACTION_SAVE_UPDATE for collection: net.dev.fursan.olap.model.pojo.UserDTO.accessedForms
DEBUG org.hibernate.engine.Cascades - done cascade ACTION_SAVE_UPDATE for collection: net.dev.fursan.olap.model.pojo.UserDTO.accessedForms
DEBUG org.hibernate.engine.Cascades - done processing cascade ACTION_SAVE_UPDATE for: net.dev.fursan.olap.model.pojo.UserDTO
DEBUG net.dev.fursan.olap.web.action.LoginAction - Adding user to session
DEBUG net.dev.fursan.olap.model.security.FursanLdap - getUserAndForms invoked for username=olap
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
DEBUG org.hibernate.engine.Cascades - processing cascade ACTION_SAVE_UPDATE for: net.dev.fursan.olap.model.pojo.UserDTO
DEBUG org.hibernate.engine.Cascades - cascade ACTION_SAVE_UPDATE for collection: net.dev.fursan.olap.model.pojo.UserDTO.accessedForms
DEBUG org.hibernate.engine.Cascades - done cascade ACTION_SAVE_UPDATE for collection: net.dev.fursan.olap.model.pojo.UserDTO.accessedForms
DEBUG org.hibernate.engine.Cascades - done processing cascade ACTION_SAVE_UPDATE for: net.dev.fursan.olap.model.pojo.UserDTO
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
DEBUG org.hibernate.engine.Collections - Collection found: [net.dev.fursan.olap.model.pojo.UserDTO.accessedForms#1], was: [<unreferenced>] (initialized)
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
DEBUG org.hibernate.pretty.Printer - listing entities:
DEBUG org.hibernate.pretty.Printer - net.dev.fursan.olap.model.pojo.UserDTO{accessedForms=[], loginName=olap, fullName=olap , lastLoginDate=2005-07-31 17:47:56, id=1}
DEBUG org.hibernate.engine.ActionQueue - changes must be flushed to space: OLAP_USR
DEBUG org.hibernate.event.def.DefaultAutoFlushEventListener - Need to execute flush
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
DEBUG org.hibernate.cache.UpdateTimestampsCache - Pre-invalidating space [OLAP_USR]
DEBUG org.hibernate.persister.entity.BasicEntityPersister - Inserting entity: [net.dev.fursan.olap.model.pojo.UserDTO#1]
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.SQL - insert into OLAP_USR (USR_LGN_NAME, USR_FULL_NAME, USR_LAST_LGN, USR_ID) values (?, ?, ?, ?)
DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [net.dev.fursan.olap.model.pojo.UserDTO#1]
DEBUG org.hibernate.type.StringType - binding 'olap' to parameter: 1
DEBUG org.hibernate.type.StringType - binding 'olap' to parameter: 1
DEBUG org.hibernate.type.StringType - binding 'olap ' to parameter: 2
DEBUG org.hibernate.type.StringType - binding 'olap ' to parameter: 2
DEBUG org.hibernate.type.TimestampType - binding '2005-07-31 17:47:56' to parameter: 3
DEBUG org.hibernate.type.TimestampType - binding '2005-07-31 17:47:56' to parameter: 3
DEBUG org.hibernate.type.LongType - binding '1' to parameter: 4
DEBUG org.hibernate.type.LongType - binding '1' to parameter: 4
DEBUG org.hibernate.jdbc.AbstractBatcher - Adding to batch
DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
DEBUG org.hibernate.jdbc.AbstractBatcher - success of batch update unknown: 0
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
DEBUG org.hibernate.cache.UpdateTimestampsCache - Pre-invalidating space [OLAP_FORM_ACCESS]
DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - Inserting collection: [net.dev.fursan.olap.model.pojo.UserDTO.accessedForms#1]
DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - collection was empty
DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush
From logs it seems that the value got for sequence is 1, and also it is binded correctly. but the problem when I try to select using any sql query IDE:
SELECT min(usr_id) FROM olap_usr
The result is
-.0000000000000000000000000000000000000000000000000000007
!!!! sometimes it appears as zero, but when I used min the above value appears.
I tried and inserted another user, & I checked the logs & they are correct the identifier is 2, but even when I tried after insertion I begin gettig the following error when I sleect from this table:
SELECT usr_id FROM olap_usr
ORA-01455: Converting column overflows integer datatype
I have a testing server on 9i release 2, this problem never occurs on this DB & the sequence 1, 2 r inserted corectly, I of course switch the dialect in configuration file for oracle 9i.
I also used at first "increment" for this field as no other processes is inserting but I faced the same problem, thats y I switched to sequence trying to avoid but it seems the problem persists.
I should mention also that I just change the dialect without changing the libraryies in my web application, i.e.: I use the following:
classes12.jar, nls_charset12.jar all the time.
I know I should change the libraries when operating Oracle 8.1.6 ut I tried before & didn't work, maybe I have some advice from u guys.
Appriciate yr help.