Author: ste...@jb...
Date: 2006-08-04 13:40:56 -0400 (Fri, 04 Aug 2006)
New Revision: 10217
Added:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchFailedException.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchedTooManyRowsAffectedException.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/TooManyRowsAffectedException.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/NativeSqlSupportSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ExceptionCheckingEntity.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ParamCheckingEntity.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/oracle-mappings.hbm.xml
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/Expectations.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
Log:
ported changes for HHH-1959 to 3.2 branch
Added: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchFailedException.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchFailedException.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchFailedException.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,18 @@
+package org.hibernate.jdbc;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Indicates a failed batch entry (-3 return).
+ *
+ * @author Steve Ebersole
+ */
+public class BatchFailedException extends HibernateException {
+ public BatchFailedException(String s) {
+ super( s );
+ }
+
+ public BatchFailedException(String string, Throwable root) {
+ super( string, root );
+ }
+}
Added: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchedTooManyRowsAffectedException.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchedTooManyRowsAffectedException.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BatchedTooManyRowsAffectedException.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,21 @@
+package org.hibernate.jdbc;
+
+/**
+ * Much like {@link TooManyRowsAffectedException}, indicates that more
+ * rows than what we were expcecting were affected. Additionally, this form
+ * occurs from a batch and carries along the batch positon that failed.
+ *
+ * @author Steve Ebersole
+ */
+public class BatchedTooManyRowsAffectedException extends TooManyRowsAffectedException {
+ private final int batchPosition;
+
+ public BatchedTooManyRowsAffectedException(String message, int expectedRowCount, int actualRowCount, int batchPosition) {
+ super( message, expectedRowCount, actualRowCount );
+ this.batchPosition = batchPosition;
+ }
+
+ public int getBatchPosition() {
+ return batchPosition;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/Expectations.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/Expectations.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/Expectations.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -54,7 +54,7 @@
}
}
else if ( rowCount == -3 ) {
- throw new HibernateException( "Batch update failed: " + batchPosition );
+ throw new BatchFailedException( "Batch update failed: " + batchPosition );
}
else {
if ( expectedRowCount > rowCount ) {
@@ -65,11 +65,10 @@
);
}
if ( expectedRowCount < rowCount ) {
- throw new HibernateException(
- "Batch update returned unexpected row count from update [" + batchPosition +
- "]; actual row count: " + rowCount +
- "; expected: " + expectedRowCount
- );
+ String msg = "Batch update returned unexpected row count from update [" +
+ batchPosition + "]; actual row count: " + rowCount +
+ "; expected: " + expectedRowCount;
+ throw new BatchedTooManyRowsAffectedException( msg, expectedRowCount, rowCount, batchPosition );
}
}
}
@@ -81,9 +80,8 @@
);
}
if ( expectedRowCount < rowCount ) {
- throw new HibernateException(
- "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount
- );
+ String msg = "Unexpected row count: " + rowCount + "; expected: " + expectedRowCount;
+ throw new TooManyRowsAffectedException( msg, expectedRowCount, rowCount );
}
}
Added: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/TooManyRowsAffectedException.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/TooManyRowsAffectedException.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/TooManyRowsAffectedException.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,29 @@
+package org.hibernate.jdbc;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Indicates that more rows were affected then we were expecting to be.
+ * Typically indicates presence of duplicate "PK" values in the
+ * given table.
+ *
+ * @author Steve Ebersole
+ */
+public class TooManyRowsAffectedException extends HibernateException {
+ private final int expectedRowCount;
+ private final int actualRowCount;
+
+ public TooManyRowsAffectedException(String message, int expectedRowCount, int actualRowCount) {
+ super( message );
+ this.expectedRowCount = expectedRowCount;
+ this.actualRowCount = actualRowCount;
+ }
+
+ public int getExpectedRowCount() {
+ return expectedRowCount;
+ }
+
+ public int getActualRowCount() {
+ return actualRowCount;
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -24,8 +24,10 @@
import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.StaleObjectStateException;
+import org.hibernate.StaleStateException;
import org.hibernate.jdbc.Expectation;
import org.hibernate.jdbc.Expectations;
+import org.hibernate.jdbc.TooManyRowsAffectedException;
import org.hibernate.dialect.lock.LockingStrategy;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.CacheKey;
@@ -1683,8 +1685,11 @@
return createEntityLoader( lockMode, CollectionHelper.EMPTY_MAP );
}
- protected boolean check(int rows, Serializable id, int tableNumber) throws HibernateException {
- if ( rows < 1 ) {
+ protected boolean check(int rows, Serializable id, int tableNumber, Expectation expectation, PreparedStatement statement) throws HibernateException {
+ try {
+ expectation.verifyOutcome( rows, statement, -1 );
+ }
+ catch( StaleStateException e ) {
if ( !isNullableTable( tableNumber ) ) {
if ( getFactory().getStatistics().isStatisticsEnabled() ) {
getFactory().getStatisticsImplementor()
@@ -1693,13 +1698,16 @@
throw new StaleObjectStateException( getEntityName(), id );
}
}
- else if ( rows > 1 ) {
+ catch( TooManyRowsAffectedException e ) {
throw new HibernateException(
"Duplicate identifier in table for: " +
MessageHelper.infoString( this, id, getFactory() )
);
}
- return rows > 0; //it could be zero if we have a "nullable" table
+ catch ( Throwable t ) {
+ return false;
+ }
+ return true;
}
protected String generateUpdateString(boolean[] includeProperty, int j, boolean useRowId) {
@@ -2173,7 +2181,7 @@
session.getBatcher().addToBatch( expectation );
}
else {
- insert.executeUpdate();
+ expectation.verifyOutcome( insert.executeUpdate(), insert, -1 );
}
}
@@ -2330,7 +2338,7 @@
return true;
}
else {
- return check( update.executeUpdate(), id, j );
+ return check( update.executeUpdate(), id, j, expectation, update );
}
}
@@ -2431,7 +2439,7 @@
session.getBatcher().addToBatch( expectation );
}
else {
- check( delete.executeUpdate(), id, j );
+ check( delete.executeUpdate(), id, j, expectation, delete );
}
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -5,6 +5,9 @@
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
+import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
import org.hibernate.test.array.ArrayTest;
import org.hibernate.test.ast.ASTIteratorTest;
import org.hibernate.test.ast.ASTUtilTest;
@@ -54,6 +57,7 @@
import org.hibernate.test.join.JoinTest;
import org.hibernate.test.joinedsubclass.JoinedSubclassTest;
import org.hibernate.test.joinfetch.JoinFetchTest;
+import org.hibernate.test.jpa.JPAComplianceSuite;
import org.hibernate.test.lazycache.InstrumentCacheTest;
import org.hibernate.test.lazycache.InstrumentCacheTest2;
import org.hibernate.test.lazyonetoone.LazyOneToOneTest;
@@ -104,12 +108,7 @@
import org.hibernate.test.readonly.ReadOnlyTest;
import org.hibernate.test.rowid.RowIdTest;
import org.hibernate.test.sorted.SortTest;
-import org.hibernate.test.sql.DataDirectOracleSQLTest;
-import org.hibernate.test.sql.Db2SQLTest;
-import org.hibernate.test.sql.GeneralTest;
-import org.hibernate.test.sql.MSSQLTest;
-import org.hibernate.test.sql.MySQLTest;
-import org.hibernate.test.sql.OracleSQLTest;
+import org.hibernate.test.sql.NativeSqlSupportSuite;
import org.hibernate.test.stats.SessionStatsTest;
import org.hibernate.test.stats.StatsTest;
import org.hibernate.test.subclassfilter.DiscrimSubclassFilterTest;
@@ -131,10 +130,6 @@
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
-import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
-import org.hibernate.test.jpa.JPAComplianceSuite;
-import org.hibernate.dialect.Dialect;
/**
* @author Gavin King
@@ -224,12 +219,7 @@
suite.addTest( org.hibernate.test.joineduid.PropertyRefTest.suite() );
suite.addTest( org.hibernate.test.orphan.PropertyRefTest.suite() );
suite.addTest( SubclassPropertyRefTest.suite() );
- suite.addTest( Db2SQLTest.suite() );
- suite.addTest( DataDirectOracleSQLTest.suite() );
- suite.addTest( OracleSQLTest.suite() );
- suite.addTest( MSSQLTest.suite() );
- suite.addTest( MySQLTest.suite() );
- suite.addTest( GeneralTest.suite() );
+ suite.addTest( NativeSqlSupportSuite.suite() );
suite.addTest( CriteriaQueryTest.suite() );
suite.addTest( SubselectTest.suite() );
suite.addTest( SubselectFetchTest.suite() );
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/NativeSqlSupportSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/NativeSqlSupportSuite.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/NativeSqlSupportSuite.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,24 @@
+package org.hibernate.test.sql;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.hibernate.test.sql.check.OracleCheckStyleTest;
+
+/**
+ * todo: describe NativeSqlSupportSuite
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSqlSupportSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "Native SQL support tests" );
+ suite.addTest( Db2SQLTest.suite() );
+ suite.addTest( DataDirectOracleSQLTest.suite() );
+ suite.addTest( OracleSQLTest.suite() );
+ suite.addTest( MSSQLTest.suite() );
+ suite.addTest( MySQLTest.suite() );
+ suite.addTest( GeneralTest.suite() );
+ suite.addTest( OracleCheckStyleTest.suite() );
+ return suite;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ExceptionCheckingEntity.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ExceptionCheckingEntity.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ExceptionCheckingEntity.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,30 @@
+package org.hibernate.test.sql.check;
+
+/**
+ * An entity which is expected to be mapped to each database using stored
+ * procedures which throw exceptions on their own; in other words, using
+ * {@link org.hibernate.engine.ExecuteUpdateResultCheckStyle#NONE}.
+ *
+ * @author Steve Ebersole
+ */
+public class ExceptionCheckingEntity {
+ private Long id;
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
+
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/OracleCheckStyleTest.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,29 @@
+package org.hibernate.test.sql.check;
+
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * todo: describe OracleCheckStyleTest
+ *
+ * @author Steve Ebersole
+ */
+public class OracleCheckStyleTest extends ResultCheckStyleTest {
+ public OracleCheckStyleTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "sql/check/oracle-mappings.hbm.xml" };
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof Oracle9Dialect;
+ }
+
+ public static Test suite() {
+ return new TestSuite( OracleCheckStyleTest.class );
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ParamCheckingEntity.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ParamCheckingEntity.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ParamCheckingEntity.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,29 @@
+package org.hibernate.test.sql.check;
+
+/**
+ * An entity which is expected to be mapped to each database using stored
+ * procedures which return "affected row counts"; in other words, using
+ * {@link org.hibernate.engine.ExecuteUpdateResultCheckStyle#PARAM}.
+ *
+ * @author Steve Ebersole
+ */
+public class ParamCheckingEntity {
+ private Long id;
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/ResultCheckStyleTest.java 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,135 @@
+package org.hibernate.test.sql.check;
+
+import org.hibernate.test.DatabaseSpecificTestCase;
+import org.hibernate.Session;
+import org.hibernate.JDBCException;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+
+/**
+ * todo: describe ResultCheckStyleTest
+ *
+ * @author Steve Ebersole
+ */
+public abstract class ResultCheckStyleTest extends DatabaseSpecificTestCase {
+
+ public ResultCheckStyleTest(String name) {
+ super( name );
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
+
+ public void testInsertionFailureWithExceptionChecking() {
+ Session s = openSession();
+ s.beginTransaction();
+ ExceptionCheckingEntity e = new ExceptionCheckingEntity();
+ e.setName( "dummy" );
+ s.save( e );
+ try {
+ s.flush();
+ fail( "expection flush failure!" );
+ }
+ catch( JDBCException ex ) {
+ // these should specifically be JDBCExceptions...
+ }
+ s.clear();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testInsertionFailureWithParamChecking() {
+ Session s = openSession();
+ s.beginTransaction();
+ ParamCheckingEntity e = new ParamCheckingEntity();
+ e.setName( "dummy" );
+ s.save( e );
+ try {
+ s.flush();
+ fail( "expection flush failure!" );
+ }
+ catch( HibernateException ex ) {
+ // these should specifically be HibernateExceptions...
+ }
+ s.clear();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testUpdateFailureWithExceptionChecking() {
+ Session s = openSession();
+ s.beginTransaction();
+ ExceptionCheckingEntity e = new ExceptionCheckingEntity();
+ e.setId( new Long( 1 ) );
+ e.setName( "dummy" );
+ s.update( e );
+ try {
+ s.flush();
+ fail( "expection flush failure!" );
+ }
+ catch( JDBCException ex ) {
+ // these should specifically be JDBCExceptions...
+ }
+ s.clear();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testUpdateFailureWithParamChecking() {
+ Session s = openSession();
+ s.beginTransaction();
+ ParamCheckingEntity e = new ParamCheckingEntity();
+ e.setId( new Long( 1 ) );
+ e.setName( "dummy" );
+ s.update( e );
+ try {
+ s.flush();
+ fail( "expection flush failure!" );
+ }
+ catch( HibernateException ex ) {
+ // these should specifically be HibernateExceptions...
+ }
+ s.clear();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testDeleteWithExceptionChecking() {
+ Session s = openSession();
+ s.beginTransaction();
+ ExceptionCheckingEntity e = new ExceptionCheckingEntity();
+ e.setId( new Long( 1 ) );
+ e.setName( "dummy" );
+ s.delete( e );
+ try {
+ s.flush();
+ fail( "expection flush failure!" );
+ }
+ catch( JDBCException ex ) {
+ // these should specifically be JDBCExceptions...
+ }
+ s.clear();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testDeleteWithParamChecking() {
+ Session s = openSession();
+ s.beginTransaction();
+ ParamCheckingEntity e = new ParamCheckingEntity();
+ e.setId( new Long( 1 ) );
+ e.setName( "dummy" );
+ s.delete( e );
+ try {
+ s.flush();
+ fail( "expection flush failure!" );
+ }
+ catch( HibernateException ex ) {
+ // these should specifically be HibernateExceptions...
+ }
+ s.clear();
+ s.getTransaction().commit();
+ s.close();
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/oracle-mappings.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/oracle-mappings.hbm.xml 2006-08-04 17:39:14 UTC (rev 10216)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/check/oracle-mappings.hbm.xml 2006-08-04 17:40:56 UTC (rev 10217)
@@ -0,0 +1,103 @@
+<?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 package="org.hibernate.test.sql.check">
+
+ <class name="ExceptionCheckingEntity" table="ENTITY_E">
+ <id name="id" unsaved-value="0" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <sql-insert callable="true" check="none">{call createEntityE(?,?)}</sql-insert>
+ <sql-update callable="true" check="none">{call updateEntityE(?,?)}</sql-update>
+ <sql-delete callable="true" check="none">{call deleteEntityE(?)}</sql-delete>
+ </class>
+
+ <class name="ParamCheckingEntity" table="ENTITY_P">
+ <id name="id" unsaved-value="0" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <sql-insert callable="true" check="param">{call createEntityP(?,?,?)}</sql-insert>
+ <sql-update callable="true" check="param">{? = call updateEntityP(?,?)}</sql-update>
+ <sql-delete callable="true" check="param">{? = call deleteEntityP(?)}</sql-delete>
+ </class>
+
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE PROCEDURE createEntityE(p_name ENTITY_E.NAME%TYPE, p_id ENTITY_E.ID%TYPE)
+ AS BEGIN
+ RAISE_APPLICATION_ERROR( -20001, 'Insert failure checking' );
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE createEntityE;
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE PROCEDURE updateEntityE(p_name ENTITY_E.NAME%TYPE, p_id ENTITY_E.ID%TYPE)
+ AS BEGIN
+ RAISE_APPLICATION_ERROR( -20001, 'Update failure checking' );
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE updateEntityE;
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE PROCEDURE deleteEntityE(p_id ENTITY_E.ID%TYPE)
+ AS BEGIN
+ RAISE_APPLICATION_ERROR( -20001, 'Update failure checking' );
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE deleteEntityE;
+ </drop>
+ </database-object>
+
+
+ <database-object>
+ <!-- Demonstrate using an Oracle procedure and a registered OUT paramater as part of hand supplied sql -->
+ <create>
+ CREATE OR REPLACE PROCEDURE createEntityP(result OUT INTEGER, p_name ENTITY_E.NAME%TYPE, p_id ENTITY_E.ID%TYPE)
+ AS BEGIN
+ /* force a failure by returning a non-1 result */
+ result := 2;
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE createEntityP;
+ </drop>
+ </database-object>
+
+ <database-object>
+ <!-- Demonstrate using an Oracle function and it's return value as part of hand supplied sql -->
+ <create>
+ CREATE OR REPLACE FUNCTION updateEntityP(p_name ENTITY_E.NAME%TYPE, p_id ENTITY_E.ID%TYPE)
+ RETURN INTEGER IS BEGIN
+ RETURN 2;
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE updateEntityP;
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE FUNCTION deleteEntityP(p_id ENTITY_E.ID%TYPE)
+ RETURN INTEGER IS BEGIN
+ RETURN 2;
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE deleteEntityE;
+ </drop>
+ </database-object>
+
+</hibernate-mapping>
\ No newline at end of file
|