FileDocCategorySizeDatePackage
CustomStoredProcTestSupport.javaAPI DocHibernate 3.2.52452Tue May 08 16:56:00 BST 2007org.hibernate.test.sql.hand.custom

CustomStoredProcTestSupport

public abstract class CustomStoredProcTestSupport extends CustomSQLTestSupport
Abstract test case defining tests of stored procedure support.
author
Gail Badner

Fields Summary
Constructors Summary
public CustomStoredProcTestSupport(String name)

		super( name );
	
Methods Summary
public voidtestEntityStoredProcedure()

		Session s = openSession();
		Transaction t = s.beginTransaction();

		Organization ifa = new Organization( "IFA" );
		Organization jboss = new Organization( "JBoss" );
		Person gavin = new Person( "Gavin" );
		Employment emp = new Employment( gavin, jboss, "AU" );
		s.persist( ifa );
		s.persist( jboss );
		s.persist( gavin );
		s.persist( emp );

		Query namedQuery = s.getNamedQuery( "selectAllEmployments" );
		List list = namedQuery.list();
		assertTrue( list.get( 0 ) instanceof Employment );
		s.delete( emp );
		s.delete( ifa );
		s.delete( jboss );
		s.delete( gavin );

		t.commit();
		s.close();
	
public voidtestParameterHandling()

		Session s = openSession();

		Query namedQuery = s.getNamedQuery( "paramhandling" );
		namedQuery.setLong( 0, 10 );
		namedQuery.setLong( 1, 20 );
		List list = namedQuery.list();
		Object[] o = ( Object[] ) list.get( 0 );
		assertEquals( o[0], new Long( 10 ) );
		assertEquals( o[1], new Long( 20 ) );

		namedQuery = s.getNamedQuery( "paramhandling_mixed" );
		namedQuery.setLong( 0, 10 );
		namedQuery.setLong( "second", 20 );
		list = namedQuery.list();
		o = ( Object[] ) list.get( 0 );
		assertEquals( o[0], new Long( 10 ) );
		assertEquals( o[1], new Long( 20 ) );
		s.close();
	
public voidtestScalarStoredProcedure()

		Session s = openSession();
		Query namedQuery = s.getNamedQuery( "simpleScalar" );
		namedQuery.setLong( "number", 43 );
		List list = namedQuery.list();
		Object o[] = ( Object[] ) list.get( 0 );
		assertEquals( o[0], "getAll" );
		assertEquals( o[1], new Long( 43 ) );
		s.close();