-->
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: Database Error not thrown as Exception
PostPosted: Wed Oct 12, 2005 11:48 am 
Newbie

Joined: Wed Oct 12, 2005 11:17 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

hibernate.cfg.xml:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
   <property name="myeclipse.connection.profile">Test</property>
   <property name="connection.url">jdbc:oracle:oci:@TEST</property>
   <property name="connection.username">usr</property>
   <property name="connection.password">pass</property>
   <property name="connection.driver_class">
      oracle.jdbc.driver.OracleDriver
   </property>
   <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
   
   <!--  c3p0  configuration -->
   <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
   <property name="hibernate.c3po.acquire_increment">3</property>
   <property name="hibernate.c3po.idle_test_period">3000</property>
   <property name="hibernate.c3p0.min_pool_size">10</property>
   <property name="hibernate.c3p0.max_pool_size">150</property>
   <property name="hibernate.c3p0.max_statements">300</property>
   <property name="hibernate.c3po.max_idle_time">30</property>
   
   <mapping resource="company.schema/InterfaceAudit.hbm.xml" />

</session-factory>

</hibernate-configuration>



interface_audit.hbm.xml:
Code:
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Sat Sep 03 13:32:47 CST 2005                         -->
<hibernate-mapping package="schema">

    <class name="InterfaceAudit" table="INTERFACE_AUDIT">
        <id name="transaction" column="TRANSACTION" type="long">
            <generator class="assigned"/>
        </id>

        <property name="transactionType" column="TRANSACTION_TYPE" type="string" />
        <property name="transactionObject" column="TRANSACTION_OBJECT" type="string" />
        <property name="transactionMethod" column="TRANSACTION_METHOD" type="string" />
        <property name="transactionDate" column="TRANSACTION_DATE" type="date" />
        <property name="transactionUser" column="TRANSACTION_USER" type="string" />
        <property name="exceptionId" column="EXCEPTION_ID" type="long" />
        <property name="exceptionDetail" column="EXCEPTION_DETAIL" type="string" />
        <property name="exceptionByCompany" column="EXCEPTION_BY_COMPANY" type="string" />
        <property name="exceptionNeedsToBProcessed" column="EXCEPTION_NEEDS_TO_B_PROCESSED" type="string" />
        <property name="exceptionWasProcessed" column="EXCEPTION_WAS_PROCESSED" type="string" />
        <property name="messageNeedsToBeSent" column="MESSAGE_NEEDS_TO_BE_SENT" type="string" />
        <property name="messageWasSent" column="MESSAGE_WAS_SENT" type="string" />
        <property name="messageProcessedBy" column="MESSAGE_PROCESSED_BY" type="string" />
        <property name="messageProcessedDate" column="MESSAGE_PROCESSED_DATE" type="date" />
        <property name="messageExceptionId" column="MESSAGE_EXCEPTION_ID" type="long" />
        <property name="messageExceptionDetail" column="MESSAGE_EXCEPTION_DETAIL" type="string" />
        <property name="exceptionClass" column="EXCEPTION_CLASS" type="string" />
        <property name="exceptionClassCompany" column="EXCEPTION_CLASS_COMPANY" type="string" />
        <property name="exceptionStackTrace" column="EXCEPTION_STACK_TRACE" type="string" />
        <property name="createdBy" column="CREATED_BY" type="string" />
        <property name="createdDate" column="CREATED_DATE" type="date" />
        <property name="modifiedBy" column="MODIFIED_BY" type="string" />
        <property name="modifiedDate" column="MODIFIED_DATE" type="date" />

        <set name="interfaceDataSet" inverse="true">
            <key column="TRANSACTION"/>
            <one-to-many class="InterfaceData"/>
        </set>


    </class>
   
</hibernate-mapping>
 


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

Code:
List myList;
InterfaceAudit ia = null;
String createdBy = null;
String sql = "SELECT {IA.*} "
   + "FROM ODB.INTERFACE_AUDIT {IA} "
   + "WHERE TRANSACTION = '133085' ";

myList = session.createSQLQuery(sql)
      .addEntity("IA", InterfaceAudit.class )
      .list();
      
for( int i = 0; i< myList.size(); i++ ){
   Transaction tx = session.beginTransaction();
   ia = (InterfaceAudit)(myList.get(i));
   ia.setCreatedBy("TEST1");
   tx.commit();
}



Full stack trace of any exception that occurs:
None (That's the problem!!!)

Name and version of the database you are using:
Oracle 9.2.0.1.0


The generated SQL (show_sql=true):
Code:
Hibernate: SELECT IA.TRANSACTION as TRANSACT1_0_, IA.TRANSACTION_TYPE as TRANSACT2_0_0_, IA.TRANSACTION_OBJECT as TRANSACT3_0_0_, IA.TRANSACTION_METHOD as TRANSACT4_0_0_, IA.TRANSACTION_DATE as TRANSACT5_0_0_, IA.TRANSACTION_USER as TRANSACT6_0_0_, IA.EXCEPTION_ID as EXCEPTION7_0_0_, IA.EXCEPTION_DETAIL as EXCEPTION8_0_0_, IA.EXCEPTION_BY_TRAX as EXCEPTION9_0_0_, IA.EXCEPTION_NEEDS_TO_B_PROCESSED as EXCEPTION10_0_0_, IA.EXCEPTION_WAS_PROCESSED as EXCEPTION11_0_0_, IA.MESSAGE_NEEDS_TO_BE_SENT as MESSAGE12_0_0_, IA.MESSAGE_WAS_SENT as MESSAGE13_0_0_, IA.MESSAGE_PROCESSED_BY as MESSAGE14_0_0_, IA.MESSAGE_PROCESSED_DATE as MESSAGE15_0_0_, IA.MESSAGE_EXCEPTION_ID as MESSAGE16_0_0_, IA.MESSAGE_EXCEPTION_DETAIL as MESSAGE17_0_0_, IA.EXCEPTION_CLASS as EXCEPTION18_0_0_, IA.EXCEPTION_CLASS_TRAX as EXCEPTION19_0_0_, IA.EXCEPTION_STACK_TRACE as EXCEPTION20_0_0_, IA.CREATED_BY as CREATED21_0_0_, IA.CREATED_DATE as CREATED22_0_0_, IA.MODIFIED_BY as MODIFIED23_0_0_, IA.MODIFIED_DATE as MODIFIED24_0_0_ FROM ODB.INTERFACE_AUDIT IA WHERE TRANSACTION = '133085'
Hibernate: update INTERFACE_AUDIT set TRANSACTION_TYPE=?, TRANSACTION_OBJECT=?, TRANSACTION_METHOD=?, TRANSACTION_DATE=?, TRANSACTION_USER=?, EXCEPTION_ID=?, EXCEPTION_DETAIL=?, EXCEPTION_BY_TRAX=?, EXCEPTION_NEEDS_TO_B_PROCESSED=?, EXCEPTION_WAS_PROCESSED=?, MESSAGE_NEEDS_TO_BE_SENT=?, MESSAGE_WAS_SENT=?, MESSAGE_PROCESSED_BY=?, MESSAGE_PROCESSED_DATE=?, MESSAGE_EXCEPTION_ID=?, MESSAGE_EXCEPTION_DETAIL=?, EXCEPTION_CLASS=?, EXCEPTION_CLASS_TRAX=?, EXCEPTION_STACK_TRACE=?, CREATED_BY=?, CREATED_DATE=?, MODIFIED_BY=?, MODIFIED_DATE=? where TRANSACTION=?


Debug level Hibernate log excerpt:

Code:
7890 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister  - Dehydrating entity: [company.schema.InterfaceAudit#133085]
7890 [main] DEBUG org.hibernate.type.StringType  - binding 'OUT' to parameter: 1
7890 [main] DEBUG org.hibernate.type.StringType  - binding 'SPEC2K_XML' to parameter: 2
7890 [main] DEBUG org.hibernate.type.StringType  - binding 'ADD' to parameter: 3
7890 [main] DEBUG org.hibernate.type.DateType  - binding '10 October 2005' to parameter: 4
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 5
7890 [main] DEBUG org.hibernate.type.LongType  - binding null to parameter: 6
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 7
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 8
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 9
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 10
7890 [main] DEBUG org.hibernate.type.StringType  - binding 'Y' to parameter: 11
7890 [main] DEBUG org.hibernate.type.StringType  - binding 'Y' to parameter: 12
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 13
7890 [main] DEBUG org.hibernate.type.DateType  - binding null to parameter: 14
7890 [main] DEBUG org.hibernate.type.LongType  - binding null to parameter: 15
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 16
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 17
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 18
7890 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 19
7890 [main] DEBUG org.hibernate.type.StringType  - binding 'TEST1' to parameter: 20
7890 [main] DEBUG org.hibernate.type.DateType  - binding null to parameter: 21
7906 [main] DEBUG org.hibernate.type.StringType  - binding null to parameter: 22
7906 [main] DEBUG org.hibernate.type.DateType  - binding null to parameter: 23
7906 [main] DEBUG org.hibernate.type.LongType  - binding '133085' to parameter: 24
7906 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - Adding to batch
7906 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - Executing batch size: 1
7906 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - success of batch update unknown: 0
7906 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
7906 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - closing statement
7906 [main] DEBUG com.mchange.v2.c3p0.stmt.GooGooStatementCache  - checkinStatement(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
7906 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener  - post flush
7906 [main] DEBUG org.hibernate.jdbc.JDBCContext  - before transaction completion
7906 [main] DEBUG org.hibernate.impl.SessionImpl  - before transaction completion
7906 [main] DEBUG org.hibernate.transaction.JDBCTransaction  - committed JDBC Connection
7906 [main] DEBUG org.hibernate.jdbc.JDBCContext  - after transaction completion
7906 [main] DEBUG org.hibernate.impl.SessionImpl  - after transaction completion
7906 [main] DEBUG org.hibernate.impl.SessionImpl  - closing session
7906 [main] DEBUG org.hibernate.jdbc.ConnectionManager  - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
7906 [main] DEBUG com.mchange.v2.c3p0.stmt.GooGooStatementCache  - checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
7921 [main] DEBUG com.mchange.v2.c3p0.impl.NewPooledConnection  - A Throwable occurred while trying to reset the typeMap property of our Connection to Collections.EMPTY_MAP!
java.lang.UnsupportedOperationException
   at java.util.AbstractMap.put(AbstractMap.java:223)
   at oracle.jdbc.driver.PhysicalConnection.addClassMapEntry(PhysicalConnection.java:2466)
   at oracle.jdbc.driver.PhysicalConnection.addDefaultClassMapEntriesTo(PhysicalConnection.java:2456)
   at oracle.jdbc.driver.PhysicalConnection.setTypeMap(PhysicalConnection.java:2448)
   at com.mchange.v2.c3p0.impl.NewPooledConnection.reset(NewPooledConnection.java:290)
   at com.mchange.v2.c3p0.impl.NewPooledConnection.markClosedProxyConnection(NewPooledConnection.java:247)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.close(NewProxyConnection.java:1148)
   at org.hibernate.connection.C3P0ConnectionProvider.closeConnection(C3P0ConnectionProvider.java:42)
   at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:327)
   at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:262)
   at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:194)
   at org.hibernate.impl.SessionImpl.close(SessionImpl.java:289)
   at company.hibernate.HibernateSessionFactory.closeSession(HibernateSessionFactory.java:90)
   at company.test.HibernateTest.main(HibernateTest.java:38)
7921 [main] DEBUG com.mchange.v2.resourcepool.BasicResourcePool  - trace com.mchange.v2.resourcepool.BasicResourcePool@1c6572b [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@15e234c)
7921 [main] DEBUG org.hibernate.jdbc.JDBCContext  - after transaction completion
7921 [main] DEBUG org.hibernate.impl.SessionImpl  - after transaction completion
7921 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] DEBUG com.mchange.v2.c3p0.stmt.GooGooStatementCache  - checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
7921 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] DEBUG com.mchange.v2.c3p0.impl.NewPooledConnection  - A Throwable occurred while trying to reset the typeMap property of our Connection to Collections.EMPTY_MAP!
java.lang.UnsupportedOperationException
   at java.util.AbstractMap.put(AbstractMap.java:223)
   at oracle.jdbc.driver.PhysicalConnection.addClassMapEntry(PhysicalConnection.java:2466)
   at oracle.jdbc.driver.PhysicalConnection.addDefaultClassMapEntriesTo(PhysicalConnection.java:2456)
   at oracle.jdbc.driver.PhysicalConnection.setTypeMap(PhysicalConnection.java:2448)
   at com.mchange.v2.c3p0.impl.NewPooledConnection.reset(NewPooledConnection.java:290)
   at com.mchange.v2.c3p0.impl.NewPooledConnection.markClosedProxyConnection(NewPooledConnection.java:247)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.close(NewProxyConnection.java:1148)
   at com.mchange.v1.db.sql.ConnectionUtils.attemptClose(ConnectionUtils.java:41)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.testPooledConnection(C3P0PooledConnectionPool.java:182)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.refurbishResourceOnCheckin(C3P0PooledConnectionPool.java:132)
   at com.mchange.v2.resourcepool.BasicResourcePool.attemptRefurbishResourceOnCheckin(BasicResourcePool.java:1130)
   at com.mchange.v2.resourcepool.BasicResourcePool.access$100(BasicResourcePool.java:32)
   at com.mchange.v2.resourcepool.BasicResourcePool$6.run(BasicResourcePool.java:862)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:368)


Here's the situation: I need to know when a database error occurs. In this test I placed a trigger on the table INTERFACE_AUDIT that would generate an error any time a records attempts to get updated. If run from SQLPlus I am able to get the error and the transaction fails. When running the above code the transaction still fails, but no exception is thrown to indicate that there was a problem. Are there any parameters that need to be set to detect DB errors? What am I missing?
Code:


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.