[hibernate-commits] Hibernate SVN: r11487 - trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue May 8 18:21:26 EDT 2007
Author: steve.ebersole at jboss.com
Date: 2007-05-08 18:21:25 -0400 (Tue, 08 May 2007)
New Revision: 11487
Added:
trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/CustomInsertSQLWithIdentityColumnTest.java
trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/Mappings.hbm.xml
Log:
HHH-2301 : IDENTITY + custom insert SQL (Scott Rankin and Gail Badner)
Added: trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/CustomInsertSQLWithIdentityColumnTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/CustomInsertSQLWithIdentityColumnTest.java (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/CustomInsertSQLWithIdentityColumnTest.java 2007-05-08 22:21:25 UTC (rev 11487)
@@ -0,0 +1,50 @@
+package org.hibernate.test.sql.hand.identity;
+
+import junit.framework.Test;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.Session;
+import org.hibernate.JDBCException;
+import org.hibernate.test.sql.hand.Organization;
+
+/**
+ * Custom SQL tests for combined usage of custom insert SQL and identity columns
+ *
+ * @author Gail Badner
+ */
+public class CustomInsertSQLWithIdentityColumnTest extends DatabaseSpecificFunctionalTestCase {
+
+ public CustomInsertSQLWithIdentityColumnTest(String str) {
+ super( str );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( CustomInsertSQLWithIdentityColumnTest.class );
+ }
+
+ public String[] getMappings() {
+ return new String[] {"sql/hand/identity/Mappings.hbm.xml"};
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect.supportsIdentityColumns();
+ }
+
+ public void testBadInsertionFails() {
+ Session session = openSession();
+ session.beginTransaction();
+ Organization org = new Organization( "hola!" );
+ try {
+ session.save( org );
+ session.delete( org );
+ fail( "expecting bad custom insert statement to fail" );
+ }
+ catch( JDBCException e ) {
+ // expected failure
+ }
+
+ session.getTransaction().rollback();
+ session.close();
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/Mappings.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/Mappings.hbm.xml (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/hand/identity/Mappings.hbm.xml 2007-05-08 22:21:25 UTC (rev 11487)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ This mapping demonstrates the combined use of IDENTITY PK columns and
+ custom supplied SQL statements.
+
+ @author : Gail Badner
+-->
+
+<hibernate-mapping package="org.hibernate.test.sql.hand" default-access="field">
+
+ <class name="Organization" table="ORGANIZATION">
+ <id name="id" column="ORG_ID">
+ <generator class="identity"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <!-- Intentionally bad SQL statement!!! -->
+ <sql-insert>INSERT INTO PERSON WHERE x=y</sql-insert>
+ </class>
+
+</hibernate-mapping>
More information about the hibernate-commits
mailing list