custominsertsqlwithidentitycolumntest.java

来自「hibernate 开源框架的代码 jar包希望大家能喜欢」· Java 代码 · 共 51 行

JAVA
51
字号
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();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?