Hibernate SVN: r11575 - in trunk/Hibernate3/testsuite/src/test: java/org/hibernate/test/bytecode/cglib and 12 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 03:34:56 -0400 (Sat, 26 May 2007)
New Revision: 11575
Added:
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java
Removed:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java
Modified:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java
trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
Log:
ok, thats much better
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/AllTests.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,445 +0,0 @@
-//$Id: AllTests.java 11496 2007-05-09 03:54:06Z steve.ebersole(a)jboss.com $
-package org.hibernate.test;
-
-import java.lang.reflect.Constructor;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.hibernate.dialect.Dialect;
-import org.hibernate.junit.TestSuiteVisitor;
-import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
-import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
-import org.hibernate.test.any.AnyTypeTest;
-import org.hibernate.test.array.ArrayTest;
-import org.hibernate.test.ast.ASTIteratorTest;
-import org.hibernate.test.ast.ASTUtilTest;
-import org.hibernate.test.batchfetch.BatchFetchTest;
-import org.hibernate.test.bidi.AuctionTest;
-import org.hibernate.test.bidi.AuctionTest2;
-import org.hibernate.test.bytecode.BytecodeSuite;
-import org.hibernate.test.cache.CacheSuite;
-import org.hibernate.test.cascade.RefreshTest;
-import org.hibernate.test.cid.CompositeIdTest;
-import org.hibernate.test.collection.CollectionSuite;
-import org.hibernate.test.component.ComponentSuite;
-import org.hibernate.test.compositeelement.CompositeElementTest;
-import org.hibernate.test.connections.ConnectionsSuite;
-import org.hibernate.test.criteria.CriteriaQueryTest;
-import org.hibernate.test.cuk.CompositePropertyRefTest;
-import org.hibernate.test.cut.CompositeUserTypeTest;
-import org.hibernate.test.deletetransient.DeleteTransientEntityTest;
-import org.hibernate.test.dialect.functional.DialectFunctionalTestsSuite;
-import org.hibernate.test.dialect.unit.DialectUnitTestsSuite;
-import org.hibernate.test.discriminator.DiscriminatorTest;
-import org.hibernate.test.dynamicentity.interceptor.InterceptorDynamicEntityTest;
-import org.hibernate.test.dynamicentity.tuplizer.TuplizerDynamicEntityTest;
-import org.hibernate.test.ecid.EmbeddedCompositeIdTest;
-import org.hibernate.test.entitymode.EntityModeSuite;
-import org.hibernate.test.exception.SQLExceptionConversionTest;
-import org.hibernate.test.extralazy.ExtraLazyTest;
-import org.hibernate.test.filter.DynamicFilterTest;
-import org.hibernate.test.formulajoin.FormulaJoinTest;
-import org.hibernate.test.generated.GeneratedPropertySuite;
-import org.hibernate.test.generatedkeys.GeneratedKeysSuite;
-import org.hibernate.test.hql.HQLSuite;
-import org.hibernate.test.id.MultipleHiLoPerTableGeneratorTest;
-import org.hibernate.test.idbag.IdBagTest;
-import org.hibernate.test.idclass.IdClassTest;
-import org.hibernate.test.idprops.IdentifierPropertyReferencesTest;
-import org.hibernate.test.immutable.ImmutableTest;
-import org.hibernate.test.instrument.buildtime.InstrumentTest;
-import org.hibernate.test.instrument.runtime.CGLIBInstrumentationTest;
-import org.hibernate.test.instrument.runtime.JavassistInstrumentationTest;
-import org.hibernate.test.interceptor.InterceptorTest;
-import org.hibernate.test.interfaceproxy.InterfaceProxyTest;
-import org.hibernate.test.iterate.IterateTest;
-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.keymanytoone.KeyManyToOneSuite;
-import org.hibernate.test.lazycache.InstrumentCacheTest;
-import org.hibernate.test.lazycache.InstrumentCacheTest2;
-import org.hibernate.test.lazyonetoone.LazyOneToOneTest;
-import org.hibernate.test.legacy.ABCProxyTest;
-import org.hibernate.test.legacy.ABCTest;
-import org.hibernate.test.legacy.CacheTest;
-import org.hibernate.test.legacy.ComponentNotNullTest;
-import org.hibernate.test.legacy.ConfigurationPerformanceTest;
-import org.hibernate.test.legacy.FooBarTest;
-import org.hibernate.test.legacy.FumTest;
-import org.hibernate.test.legacy.IJ2Test;
-import org.hibernate.test.legacy.IJTest;
-import org.hibernate.test.legacy.MapTest;
-import org.hibernate.test.legacy.MasterDetailTest;
-import org.hibernate.test.legacy.MultiTableTest;
-import org.hibernate.test.legacy.NonReflectiveBinderTest;
-import org.hibernate.test.legacy.OneToOneCacheTest;
-import org.hibernate.test.legacy.ParentChildTest;
-import org.hibernate.test.legacy.QueryByExampleTest;
-import org.hibernate.test.legacy.SQLFunctionsTest;
-import org.hibernate.test.legacy.SQLLoaderTest;
-import org.hibernate.test.legacy.StatisticsTest;
-import org.hibernate.test.lob.LobSuite;
-import org.hibernate.test.manytomany.ManyToManyTest;
-import org.hibernate.test.map.MapIndexFormulaTest;
-import org.hibernate.test.mapcompelem.MapCompositeElementTest;
-import org.hibernate.test.mapelemformula.MapElementFormulaTest;
-import org.hibernate.test.mapping.PersistentClassVisitorTest;
-import org.hibernate.test.mapping.ValueVisitorTest;
-import org.hibernate.test.mappingexception.MappingExceptionTest;
-import org.hibernate.test.mixed.MixedTest;
-import org.hibernate.test.naturalid.NaturalIdTest;
-import org.hibernate.test.ondelete.OnDeleteTest;
-import org.hibernate.test.onetomany.OneToManyTest;
-import org.hibernate.test.onetoone.OneToOneSuite;
-import org.hibernate.test.ops.OpsSuite;
-import org.hibernate.test.optlock.OptimisticLockTest;
-import org.hibernate.test.ordered.OrderByTest;
-import org.hibernate.test.orphan.OrphanSuite;
-import org.hibernate.test.pagination.PaginationTest;
-import org.hibernate.test.propertyref.PropertyRefSuite;
-import org.hibernate.test.proxy.ProxyTest;
-import org.hibernate.test.querycache.QueryCacheTest;
-import org.hibernate.test.readonly.ReadOnlyTest;
-import org.hibernate.test.rowid.RowIdTest;
-import org.hibernate.test.sorted.SortTest;
-import org.hibernate.test.sql.NativeSqlSupportSuite;
-import org.hibernate.test.stats.SessionStatsTest;
-import org.hibernate.test.stats.StatsTest;
-import org.hibernate.test.subclassfilter.DiscrimSubclassFilterTest;
-import org.hibernate.test.subclassfilter.JoinedSubclassFilterTest;
-import org.hibernate.test.subclassfilter.UnionSubclassFilterTest;
-import org.hibernate.test.subselect.SubselectTest;
-import org.hibernate.test.subselectfetch.SubselectFetchTest;
-import org.hibernate.test.ternary.TernaryTest;
-import org.hibernate.test.timestamp.TimestampTest;
-import org.hibernate.test.tm.CMTTest;
-import org.hibernate.test.typedmanytoone.TypedManyToOneTest;
-import org.hibernate.test.typedonetoone.TypedOneToOneTest;
-import org.hibernate.test.typeparameters.TypeParameterTest;
-import org.hibernate.test.unconstrained.UnconstrainedTest;
-import org.hibernate.test.unidir.BackrefTest;
-import org.hibernate.test.unionsubclass.UnionSubclassTest;
-import org.hibernate.test.usercollection.UserCollectionTypeSuite;
-import org.hibernate.test.util.UtilSuite;
-import org.hibernate.test.version.VersionTest;
-import org.hibernate.test.version.db.DbVersionTest;
-import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
-import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.insertordering.InsertOrderingTest;
-import org.hibernate.test.reattachment.ReattachmentSuite;
-
-/**
- * @author Gavin King
- */
-public class AllTests {
-
- /**
- * Returns the entire test suite (both legacy and new
- *
- * @return the entire test suite
- */
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest( NewTests.suite() );
- suite.addTest( LegacyTests.suite() );
- return suite;
- }
-
- /**
- * Returns the entire test suite (both legacy and new) w/o filtering
- *
- * @return the entire test suite
- */
- public static Test unfilteredSuite() {
- TestSuite suite = new TestSuite();
- suite.addTest( NewTests.unfilteredSuite() );
- suite.addTest( LegacyTests.unfilteredSuite() );
- return suite;
- }
-
- /**
- * Runs the entire test suite.
- *
- * @param args n/a
- * @see #suite
- */
- public static void main(String args[]) {
- TestRunner.run( suite() );
- }
-
- /**
- * An inner class representing the new test suite.
- */
- public static class NewTests {
-
- /**
- * Returns the new test suite (filtered)
- *
- * @return the new test suite
- */
- public static Test suite() {
- return filter( ( TestSuite ) unfilteredSuite() );
- }
-
- /**
- * Returns the new test suite (unfiltered)
- *
- * @return the new test suite
- */
- public static Test unfilteredSuite() {
- TestSuite suite = new TestSuite("New tests suite");
- suite.addTest( OpsSuite.suite() );
- suite.addTest( NaturalIdTest.suite() );
- suite.addTest( ComponentSuite.suite() );
- suite.addTest( ProxyTest.suite() );
- suite.addTest( VersionTest.suite() );
- suite.addTest( TimestampTest.suite() );
- suite.addTest( InterceptorTest.suite() );
- suite.addTest( EmbeddedCompositeIdTest.suite() );
- suite.addTest( ImmutableTest.suite() );
- suite.addTest( ReadOnlyTest.suite() );
- suite.addTest( IdClassTest.suite() );
- suite.addTest( ArrayTest.suite() );
- suite.addTest( TernaryTest.suite() );
- suite.addTest( CollectionSuite.suite() );
- suite.addTest( IdBagTest.suite() );
- suite.addTest( MapCompositeElementTest.suite() );
- suite.addTest( MapIndexFormulaTest.suite() );
- suite.addTest( MapElementFormulaTest.suite() );
- suite.addTest( BackrefTest.suite() );
- suite.addTest( BatchFetchTest.suite() );
- suite.addTest( CompositeIdTest.suite() );
- suite.addTest( CompositeElementTest.suite() );
- suite.addTest( CompositePropertyRefTest.suite() );
- suite.addTest( FormulaJoinTest.suite() );
- suite.addTest( DiscriminatorTest.suite() );
- suite.addTest( EntityModeSuite.suite() );
- suite.addTest( DynamicFilterTest.suite() );
- suite.addTest( InterfaceProxyTest.suite() );
- suite.addTest( OrphanSuite.suite() );
- suite.addTest( JoinTest.suite() );
- suite.addTest( JoinedSubclassTest.suite() );
- suite.addTest( org.hibernate.test.unionsubclass2.UnionSubclassTest.suite() );
- suite.addTest( MixedTest.suite() );
- suite.addTest( OneToManyTest.suite() );
- suite.addTest( ManyToManyTest.suite() );
- suite.addTest( OneToOneSuite.suite() );
- suite.addTest( OptimisticLockTest.suite() );
- suite.addTest( PropertyRefSuite.suite() );
- suite.addTest( NativeSqlSupportSuite.suite() );
- suite.addTest( CriteriaQueryTest.suite() );
- suite.addTest( SubselectTest.suite() );
- suite.addTest( SubselectFetchTest.suite() );
- suite.addTest( JoinFetchTest.suite() );
- suite.addTest( UnionSubclassTest.suite() );
- suite.addTest( ASTIteratorTest.suite() );
- suite.addTest( HQLSuite.suite() );
- suite.addTest( ASTUtilTest.suite() );
- suite.addTest( CacheSuite.suite() );
- suite.addTest( QueryCacheTest.suite() );
- suite.addTest( CompositeUserTypeTest.suite() );
- suite.addTest( TypeParameterTest.suite() );
- suite.addTest( TypedOneToOneTest.suite() );
- suite.addTest( TypedManyToOneTest.suite() );
- suite.addTest( CMTTest.suite() );
- suite.addTest( MultipleHiLoPerTableGeneratorTest.suite() );
- suite.addTest( UnionSubclassFilterTest.suite() );
- suite.addTest( JoinedSubclassFilterTest.suite() );
- suite.addTest( DiscrimSubclassFilterTest.suite() );
- suite.addTest( UnconstrainedTest.suite() );
- suite.addTest( RowIdTest.suite() );
- suite.addTest( OnDeleteTest.suite() );
- suite.addTest( OrderByTest.suite() );
- suite.addTest( SortTest.suite() );
- suite.addTest( WhereTest.suite() );
- suite.addTest( IterateTest.suite() );
- suite.addTest( RefreshTest.suite() );
- suite.addTest( ExtraLazyTest.suite() );
- suite.addTest( StatsTest.suite() );
- suite.addTest( SessionStatsTest.suite() );
- suite.addTest( ConnectionsSuite.suite() );
- suite.addTest( SQLExceptionConversionTest.suite() );
- suite.addTest( ValueVisitorTest.suite() );
- suite.addTest( PersistentClassVisitorTest.suite() );
- suite.addTest( AuctionTest.suite() );
- suite.addTest( AuctionTest2.suite() );
- suite.addTest( PaginationTest.suite() );
- suite.addTest( MappingExceptionTest.suite() );
- if ( InstrumentTest.isRunnable() ) {
- suite.addTest( InstrumentTest.suite() );
- }
- if ( LazyOneToOneTest.isRunnable() ) {
- suite.addTest( LazyOneToOneTest.suite() );
- }
- if ( InstrumentCacheTest.isRunnable() ) {
- suite.addTest( InstrumentCacheTest.suite() );
- }
- if ( InstrumentCacheTest2.isRunnable() ) {
- suite.addTest( InstrumentCacheTest2.suite() );
- }
- suite.addTest( CGLIBInstrumentationTest.suite() );
- suite.addTest( JavassistInstrumentationTest.suite() );
- suite.addTest( SybaseTimestampVersioningTest.suite() );
- suite.addTest( DbVersionTest.suite() );
- suite.addTest( GeneratedPropertySuite.suite() );
- suite.addTest( GeneratedKeysSuite.suite() );
- suite.addTest( InterceptorDynamicEntityTest.suite() );
- suite.addTest( TuplizerDynamicEntityTest.suite() );
- suite.addTest( BytecodeSuite.suite() );
- suite.addTest( JPAComplianceSuite.suite() );
- suite.addTest( AbstractComponentPropertyRefTest.suite() );
- suite.addTest( AbstractCompositeIdTest.suite() );
- suite.addTest( UtilSuite.suite() );
- suite.addTest( AnyTypeTest.suite() );
- suite.addTest( LobSuite.suite() );
- suite.addTest( IdentifierPropertyReferencesTest.suite() );
- suite.addTest( DeleteTransientEntityTest.suite() );
- suite.addTest( UserCollectionTypeSuite.suite() );
- suite.addTest( KeyManyToOneSuite.suite() );
- suite.addTest( DialectFunctionalTestsSuite.suite() );
- suite.addTest( DialectUnitTestsSuite.suite() );
- suite.addTest( InsertOrderingTest.suite() );
- suite.addTest( ReattachmentSuite.suite() );
-
- return suite;
- }
-
- /**
- * Runs the new test suite
- *
- * @param args n/a
- */
- public static void main(String[] args) {
- TestRunner.run( suite() );
- }
- }
-
- /**
- * An inner class representing the legacy test suite.
- */
- public static class LegacyTests {
-
- /**
- * Returns the legacy test suite
- *
- * @return the legacy test suite
- */
- public static Test suite() {
- return filter( ( TestSuite ) unfilteredSuite() );
- }
-
- /**
- * Returns the legacy test suite
- *
- * @return the legacy test suite
- */
- public static Test unfilteredSuite() {
- TestSuite suite = new TestSuite("Legacy tests suite");
- suite.addTest( FumTest.suite() );
- suite.addTest( MasterDetailTest.suite() );
- suite.addTest( ParentChildTest.suite() );
- suite.addTest( ABCTest.suite() );
- suite.addTest( ABCProxyTest.suite() );
- suite.addTest( SQLFunctionsTest.suite() );
- suite.addTest( SQLLoaderTest.suite() );
- suite.addTest( MultiTableTest.suite() );
- suite.addTest( MapTest.suite() );
- suite.addTest( QueryByExampleTest.suite() );
- suite.addTest( ComponentNotNullTest.suite() );
- suite.addTest( IJTest.suite() );
- suite.addTest( IJ2Test.suite() );
- suite.addTest( FooBarTest.suite() );
- suite.addTest( StatisticsTest.suite() );
- suite.addTest( CacheTest.suite() );
- suite.addTest( OneToOneCacheTest.suite() );
- suite.addTest( NonReflectiveBinderTest.suite() );
- suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
- return suite;
- }
-
- /**
- * Run the legacy test suite
- *
- * @param args n/a
- */
- public static void main(String[] args) {
- TestRunner.run( suite() );
- }
- }
-
- private static TestSuite filter(TestSuite testSuite) {
- FilterHandler handler = new FilterHandler();
- TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
- visitor.visit( testSuite );
- return handler.getFilteredTestSuite();
- }
-
- private static class TestSuiteStackEntry {
- public final TestSuite testSuite;
- public final TestSuiteStackEntry parentEntry;
-
- public TestSuiteStackEntry(TestSuite testSuite, TestSuiteStackEntry parentEntry) {
- this.testSuite = testSuite;
- this.parentEntry = parentEntry;
- if ( parentEntry != null ) {
- parentEntry.testSuite.addTest( testSuite );
- }
- }
- }
-
- private static class FilterHandler implements TestSuiteVisitor.Handler {
- private TestSuiteStackEntry topStackElement;
- private TestSuiteStackEntry currentStackElement;
- private Dialect dialect = Dialect.getDialect();
-
- public void handleTestCase(Test test) {
- if ( test instanceof TestCase ) {
- TestCase hibernateTestCase = ( TestCase ) test;
- if ( ! hibernateTestCase.appliesTo( dialect ) ) {
- System.out.println( "skipping test [" + hibernateTestCase.fullTestName() + "] for dialect [" + dialect.getClass().getName() + "]" );
- }
- else {
- currentStackElement.testSuite.addTest( test );
- }
- }
- else {
- currentStackElement.testSuite.addTest( test );
- }
- }
-
- public void startingTestSuite(TestSuite suite) {
- currentStackElement = new TestSuiteStackEntry( instantiateCopy( suite ), currentStackElement );
- if ( topStackElement == null ) {
- topStackElement = currentStackElement;
- }
- }
-
- public void completedTestSuite(TestSuite suite) {
- if ( currentStackElement != null ) {
- currentStackElement = currentStackElement.parentEntry;
- }
- }
-
- public TestSuite getFilteredTestSuite() {
- return topStackElement.testSuite;
- }
-
- private static final Class[] EXPECTED_CTOR_SIG = new Class[] { String.class };
-
- private TestSuite instantiateCopy(TestSuite suite) {
- try {
- Class testSuiteClass = suite.getClass();
- Constructor ctor = testSuiteClass.getDeclaredConstructor( EXPECTED_CTOR_SIG );
- ctor.setAccessible( true );
- return ( TestSuite ) ctor.newInstance( new Object[] { suite.getName() } );
- }
- catch ( Throwable t ) {
- throw new RuntimeException( "Unable to build test suite copy [" + suite + "]", t );
- }
- }
- }
-}
\ No newline at end of file
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -29,7 +29,8 @@
public static Set collectAllFailureExpectedTestNames() {
Set names = new HashSet();
- collectFailureExpectedTestNames( names, ( TestSuite ) AllTests.unfilteredSuite() );
+// todo : need to come up with a new scheme to do this...
+// collectFailureExpectedTestNames( names, ( TestSuite ) AllTests.unfilteredSuite() );
return names;
}
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestCase.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,616 +0,0 @@
-//$Id: TestCase.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.com $
-package org.hibernate.test;
-
-import java.sql.Blob;
-import java.sql.Clob;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.AssertionFailedError;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.DB2Dialect;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.DerbyDialect;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.SimpleValue;
-
-public abstract class TestCase extends junit.framework.TestCase {
-
- private static SessionFactory sessions;
- private static Configuration cfg;
- private static Dialect dialect;
- private static Class lastTestClass;
- private org.hibernate.classic.Session session;
-
- public TestCase(String name) {
- super( name );
- }
-
-
- // methods for subclasses to change test environment ~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the mapping resources to be used to build the configuration.
- * <p/>
- * Resources should be relative to {@link #getBaseForMappings()}
- *
- * @return The mapping resources
- */
- protected abstract String[] getMappings();
-
- /**
- * The base name for relative mapping resources. The default is
- * <tt>org/hibernate/test/</tt>
- *
- * @return the mapping resource base
- */
- protected String getBaseForMappings() {
- return "org/hibernate/test/";
- }
-
- /**
- * Should the database schema be (re)created
- *
- * @return True for auto export (including recreation on test failure).
- */
- protected boolean recreateSchema() {
- return true;
- }
-
- protected boolean dropAfterFailure() {
- return true;
- }
-
- /**
- * Apply any test-specific configuration prior to building the factory.
- *
- * @param cfg The configuration which will be used to construct the factory.
- */
- protected void configure(Configuration cfg) {
- }
-
- protected boolean overrideCacheStrategy() {
- return true;
- }
-
- protected String getCacheConcurrencyStrategy() {
- return "nonstrict-read-write";
- }
-
-
- // methods for subclasses to access environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the factory for this test environment.
- *
- * @return The factory.
- */
- protected SessionFactory getSessions() {
- return sessions;
- }
-
- /**
- * Get the factory for this test environment, casted to {@link SessionFactoryImplementor}.
- * <p/>
- * Shorthand for ( {@link SessionFactoryImplementor} ) {@link #getSessions()}...
- *
- * @return The factory
- */
- protected SessionFactoryImplementor sfi() {
- return ( SessionFactoryImplementor ) getSessions();
- }
-
- protected Dialect getDialect() {
- if ( dialect == null ) {
- dialect = Dialect.getDialect();
- }
- return dialect;
- }
-
- protected Configuration getCfg() {
- return cfg;
- }
-
- public org.hibernate.classic.Session openSession() throws HibernateException {
- session = getSessions().openSession();
- return session;
- }
-
- public org.hibernate.classic.Session openSession(Interceptor interceptor)
- throws HibernateException {
- session = getSessions().openSession(interceptor);
- return session;
- }
-
-
- // JUnit hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * The Hibernate test suite tries to only build the db schema once
- * per test class (not test case which = instance) hence all the
- * static vars.
- * <p/>
- * Here is the crux of that attempt. We only build a factory when one was
- * not previously built, or when we start a new test class.
- *
- * @throws Exception
- */
- protected void setUp() throws Exception {
- if ( getSessions() == null || lastTestClass != getClass() ) {
- buildSessionFactory();
- lastTestClass = getClass();
- }
- }
-
-
- private void buildSessionFactory() throws Exception {
- if ( getSessions()!=null ) {
- getSessions().close();
- }
-
- TestCase.dialect = Dialect.getDialect();
- if ( ! appliesTo( getDialect() ) ) {
- return;
- }
-
- try {
-
- TestCase.cfg = new Configuration();
- cfg.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.HashtableCacheProvider" );
- if( recreateSchema() ) {
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- }
- addMappings( getMappings(), cfg );
- configure( cfg );
-
- if ( getCacheConcurrencyStrategy() != null ) {
- Iterator iter = cfg.getClassMappings();
- while ( iter.hasNext() ) {
- PersistentClass clazz = (PersistentClass) iter.next();
- Iterator props = clazz.getPropertyClosureIterator();
- boolean hasLob = false;
- while ( props.hasNext() ) {
- Property prop = (Property) props.next();
- if ( prop.getValue().isSimpleValue() ) {
- String type = ( (SimpleValue) prop.getValue() ).getTypeName();
- if ( "blob".equals(type) || "clob".equals(type) ) hasLob = true;
- if ( Blob.class.getName().equals(type) || Clob.class.getName().equals(type) ) hasLob = true;
- }
- }
- if ( !hasLob && !clazz.isInherited() && overrideCacheStrategy() ) {
- cfg.setCacheConcurrencyStrategy(
- clazz.getEntityName(),
- getCacheConcurrencyStrategy()
- );
- }
- }
- iter = cfg.getCollectionMappings();
- while ( iter.hasNext() ) {
- Collection coll = (Collection) iter.next();
- cfg.setCollectionCacheConcurrencyStrategy(
- coll.getRole(),
- getCacheConcurrencyStrategy()
- );
- }
- }
-
- // make sure we use the same dialect...
- cfg.setProperty( Environment.DIALECT, TestCase.dialect.getClass().getName() );
- TestCase.sessions = cfg.buildSessionFactory();
- afterSessionFactoryBuilt();
- }
- catch ( Exception e ) {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected void addMappings(String[] files, Configuration cfg) {
- for ( int i = 0; i < files.length; i++ ) {
- if ( !files[i].startsWith( "net/" ) ) {
- files[i] = getBaseForMappings() + files[i];
- }
- cfg.addResource( files[i], TestCase.class.getClassLoader() );
- }
- }
-
- protected void afterSessionFactoryBuilt() throws Exception {
- // for subclasses to override in order to perform extra "stuff" only
- // when SF (re)built...
- }
-
- protected void runTest() throws Throwable {
- final boolean stats = sessions.getStatistics().isStatisticsEnabled();
- try {
- if ( stats ) {
- sessions.getStatistics().clear();
- }
-
- super.runTest();
-
- if ( stats ) {
- sessions.getStatistics().logSummary();
- }
-
- if ( session != null && session.isOpen() ) {
- if ( session.isConnected() ) {
- session.connection().rollback();
- }
- session.close();
- session = null;
- fail( "unclosed session" );
- }
- else {
- session = null;
- }
- assertAllDataRemoved();
- }
- catch ( Throwable e ) {
- try {
- if ( session != null && session.isOpen() ) {
- if ( session.isConnected() ) {
- session.connection().rollback();
- }
- session.close();
- }
- }
- catch ( Exception ignore ) {
- }
- try {
- if ( dropAfterFailure() && sessions != null ) {
- sessions.close();
- sessions = null;
- }
- }
- catch ( Exception ignore ) {
- }
- throw e;
- }
- }
-
- public void runBare() throws Throwable {
- String sysPropName = "hibernate.test.validatefailureexpected";
- assertNotNull( getName() );
- if ( Boolean.getBoolean( sysPropName ) ) {
- if ( getName().endsWith( "FailureExpected" ) ) {
- Throwable t = null;
- try {
- super.runBare();
- }
- catch ( Throwable afe ) {
- t = afe;
- }
- if ( t == null ) {
- fail( "Test where marked as FailureExpected, but did not fail!" );
- }
- else {
- reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + t.toString() );
- }
- }
- else {
- super.runBare();
- }
- }
- else {
- super.runBare();
- }
- }
-
- protected void assertAllDataRemoved() {
- if ( !recreateSchema() ) {
- return; // no tables were created...
- }
- if ( !Boolean.getBoolean( "hibernate.test.validateDataCleanup" ) ) {
- return;
- }
-
- Session tmpSession = sessions.openSession();
- try {
- List list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();
-
- Map items = new HashMap();
- if ( !list.isEmpty() ) {
- for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
- Object element = iter.next();
- Integer l = ( Integer ) items.get( tmpSession.getEntityName( element ) );
- if ( l == null ) {
- l = new Integer( 0 );
- }
- l = new Integer( l.intValue() + 1 );
- items.put( tmpSession.getEntityName( element ), l );
- System.out.println( "Data left: " + element );
- }
- fail( "Data is left in the database: " + items.toString() );
- }
- }
- finally {
- try {
- tmpSession.close();
- }
- catch( Throwable t ) {
- // intentionally empty
- }
- }
- }
-
- public static void assertElementTypeAssignability(java.util.Collection collection, Class clazz) throws AssertionFailedError {
- Iterator itr = collection.iterator();
- while ( itr.hasNext() ) {
- assertClassAssignability( itr.next().getClass(), clazz );
- }
- }
-
- public static void assertClassAssignability(Class source, Class target) throws AssertionFailedError {
- if ( !target.isAssignableFrom( source ) ) {
- throw new AssertionFailedError(
- "Classes were not assignment-compatible : source<" + source.getName() +
- "> target<" + target.getName() + ">"
- );
- }
- }
-
-
- // test skipping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected static final Log SKIP_LOG = LogFactory.getLog("org.hibernate.test.SKIPPED");
-
- public String fullTestName() {
- return this.getName() + " (" + this.getClass().getName() + ")";
- }
-
- protected void reportSkip(String reason, String testDescription) {
- SKIP_LOG.warn( "*** skipping [" + fullTestName() + "] - " + testDescription + " : " + reason, new Exception() );
- }
-
- /**
- * Intended to indicate that this test class as a whole is intended for
- * a dialect or series of dialects. Skips here (appliesTo = false) therefore
- * simply indicate that the given tests target a particular feature of the
- * checked database and none of the tests on this class should be run for the
- * checked dialect.
- *
- * @param dialect The dialect to be checked.
- * @return True if all the tests on this class apply to the given dialect (and
- * therefore should be run); false otherwise.
- */
- public boolean appliesTo(Dialect dialect) {
- return true;
- }
-
- /**
- * Is connection at least read committed?
- * <p/>
- * Not, that this skip check relies on the JDBC driver reporting
- * the true isolation level correctly. HSQLDB, for example, will
- * report whatever you specify as the isolation
- * (Connection.setTransationIsolation()), even though it only supports
- * read-uncommitted.
- *
- * @param scenario text description of the scenario being tested.
- * @return true if read-committed isolation is maintained.
- */
- protected boolean readCommittedIsolationMaintained(String scenario) {
- int isolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
- Session testSession = null;
- try {
- testSession = openSession();
- isolation = testSession.connection().getTransactionIsolation();
- }
- catch( Throwable ignore ) {
- }
- finally {
- if ( testSession != null ) {
- try {
- testSession.close();
- }
- catch( Throwable ignore ) {
- }
- }
- }
- if ( isolation < java.sql.Connection.TRANSACTION_READ_COMMITTED ) {
- reportSkip( "environment does not support at least read committed isolation", scenario );
- return false;
- }
- else {
- return true;
- }
- }
-
- /**
- * Does the db/dialect support using a column's physical name in the order-by clause
- * even after it has been aliased in the select clause. This is not actually
- * required by the SQL spec, although virtually ever DB in the world supports this
- * (the most glaring omission here being IBM-variant DBs ala DB2 and Derby).
- *
- * @param testDescription description of the scenario being tested.
- * @return true if is allowed
- */
- protected boolean allowsPhysicalColumnNameInOrderby(String testDescription) {
- if ( DB2Dialect.class.isInstance( getDialect() ) ) {
- // https://issues.apache.org/jira/browse/DERBY-1624
- reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
- return false;
- }
- return true;
- }
-
- /**
- * Does the db/dialect support using a column's physical name in the having clause
- * even after it has been aliased in the select/group-by clause. This is not actually
- * required by the SQL spec, although virtually ever DB in the world supports this.
- *
- * @param testDescription description of the scenario being tested.
- * @return true if is allowed
- */
- protected boolean allowsPhysicalColumnNameInHaving(String testDescription) {
- // I only *know* of this being a limitation on Derby, although I highly suspect
- // it is a limitation on any IBM/DB2 variant
- if ( DerbyDialect.class.isInstance( getDialect() ) ) {
- // https://issues.apache.org/jira/browse/DERBY-1624
- reportSkip( "Dialect does not support physical column name in having clause after it is aliased", testDescription );
- return false;
- }
- return true;
- }
-
- /**
- * Does the db/dialect support empty lists in the IN operator?
- * <p/>
- * For example, is "... a.b IN () ..." supported?
- *
- * @param testDescription description of the scenario being tested.
- * @return true if is allowed
- */
- protected boolean dialectSupportsEmptyInList(String testDescription) {
- if ( ! getDialect().supportsEmptyInList() ) {
- reportSkip( "Dialect does not support SQL empty in list : x in ()", testDescription );
- return false;
- }
- return true;
- }
-
- /**
- * Is the db/dialect sensitive in terms of string comparisons?
- * @param testDescription description of the scenario being tested.
- * @return true if sensitive
- */
- protected boolean dialectIsCaseSensitive(String testDescription) {
- if ( getDialect().areStringComparisonsCaseInsensitive() ) {
- reportSkip( "Dialect is case sensitive. ", testDescription );
- return true;
- }
- return false;
- }
-
- protected boolean supportsRowValueConstructorSyntaxInInList() {
- if ( ! getDialect().supportsRowValueConstructorSyntaxInInList() ) {
- reportSkip( "Dialect does not support 'tuple' syntax as part of an IN value list", "query support" );
- return false;
- }
- return true;
- }
-
- protected boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
- if ( ! getDialect().supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() ) {
- reportSkip( "Driver does not support 'position query' methods on forward-only cursors", "query support" );
- return false;
- }
- return true;
- }
-
- protected boolean supportsCircularCascadeDelete() {
- if ( ! getDialect().supportsCircularCascadeDeleteConstraints() ) {
- reportSkip( "db/dialect does not support 'circular' cascade delete constraints", "cascade delete constraint support" );
- return false;
- }
- return true;
- }
-
- protected boolean supportsSubselectOnLeftSideIn() {
- if ( ! getDialect().supportsSubselectAsInPredicateLHS() ) {
- reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
- return false;
- }
- return true;
- }
-
- /**
- * Expected LOB usage pattern is such that I can perform an insert
- * via prepared statement with a parameter binding for a LOB value
- * without crazy casting to JDBC driver implementation-specific classes...
- * <p/>
- * Part of the trickiness here is the fact that this is largely
- * driver dependent. For Oracle, which is notoriously bad with
- * LOB support in their drivers actually does a pretty good job with
- * LOB support as of the 10.2.x versions of their drivers...
- *
- * @return True if expected usage pattern is support; false otherwise.
- */
- protected boolean supportsExpectedLobUsagePattern() {
- if ( ! getDialect().supportsExpectedLobUsagePattern() ) {
- reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
- return false;
- }
- return true;
- }
-
- /**
- * Does the current dialect support propogating changes to LOB
- * values back to the database? Talking about mutating the
- * underlying value as opposed to supplying a new
- * LOB instance...
- *
- * @return True if the changes are propogated back to the
- * database; false otherwise.
- */
- protected boolean supportsLobValueChangePropogation() {
- if ( ! getDialect().supportsLobValueChangePropogation() ) {
- reportSkip( "database/driver does not support propogating LOB value change back to database", "LOB support" );
- return false;
- }
- return true;
- }
-
- /**
- * Is it supported to materialize a LOB locator outside the transaction in
- * which it was created?
- * <p/>
- * Again, part of the trickiness here is the fact that this is largely
- * driver dependent.
- * <p/>
- * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
- * also support the ability to materialize a LOB outside the owning transaction...
- *
- * @return True if unbounded materialization is supported; false otherwise.
- */
- protected boolean supportsUnboundedLobLocatorMaterialization() {
- if ( !getDialect().supportsUnboundedLobLocatorMaterialization() ) {
- reportSkip( "database/driver does not support materializing a LOB locator outside the 'owning' transaction", "LOB support" );
- return false;
- }
- return true;
- }
-
- protected boolean supportsSubqueryOnMutatingTable() {
- if ( !getDialect().supportsSubqueryOnMutatingTable() ) {
- reportSkip( "database/driver does not support referencing mutating table in subquery", "bulk DML support" );
- return false;
- }
- return true;
- }
-
- protected boolean dialectIs(Class dialectClass) {
- return dialectClass.isInstance( getDialect() );
- }
-
- protected boolean dialectIsOneOf(Class[] dialectClasses) {
- for ( int i = 0; i < dialectClasses.length; i++ ) {
- if ( dialectClasses[i].isInstance( getDialect() ) ) {
- return true;
- }
- }
- return false;
- }
-
- protected boolean dialectIsNot(Class dialectClass) {
- return ! dialectIs( dialectClass );
- }
-
- protected boolean dialectIsNot(Class[] dialectClasses) {
- return ! dialectIsOneOf( dialectClasses );
- }
-
-}
\ No newline at end of file
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,10 +1,8 @@
package org.hibernate.test.bytecode.cglib;
-import org.hibernate.test.TestCase;
import org.hibernate.test.bytecode.Bean;
import org.hibernate.Session;
import org.hibernate.Hibernate;
-import org.hibernate.dialect.Dialect;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Environment;
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,12 +1,9 @@
// $Id: ConnectionManagementTestCase.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.com $
package org.hibernate.test.connections;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
import org.hibernate.util.SerializationHelper;
/**
@@ -110,8 +107,6 @@
/**
* Tests to validate that a session holding JDBC resources will not
* be allowed to serialize.
- *
- * @throws Throwable
*/
public final void testConnectedSerialization() throws Throwable {
prepare();
@@ -137,8 +132,6 @@
/**
* Test that a session which has been manually disconnected will be allowed
* to serialize.
- *
- * @throws Throwable
*/
public final void testManualDisconnectedSerialization() throws Throwable {
prepare();
@@ -156,8 +149,6 @@
/**
* Test that the legacy manual disconnect()/reconnect() chain works as
* expected in the given environment.
- *
- * @throws Throwable
*/
public final void testManualDisconnectChain() throws Throwable {
prepare();
@@ -185,8 +176,6 @@
* expected in the given environment. Similiar to {@link #testManualDisconnectChain}
* expect that here we force the session to acquire and hold JDBC resources
* prior to disconnecting.
- *
- * @throws Throwable
*/
public final void testManualDisconnectWithOpenResources() throws Throwable {
prepare();
@@ -220,8 +209,6 @@
/**
* Test that the basic session usage template works in all environment
* scenarios.
- *
- * @throws Throwable
*/
public void testBasicSessionUsage() throws Throwable {
prepare();
@@ -256,8 +243,6 @@
/**
* Test that session-closed protections work properly in all environments.
- *
- * @throws Throwable
*/
public void testSessionClosedProtections() throws Throwable {
prepare();
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/dynamicentity/tuplizer/TuplizerDynamicEntityTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,6 +1,5 @@
package org.hibernate.test.dynamicentity.tuplizer;
-import org.hibernate.test.TestCase;
import org.hibernate.test.dynamicentity.Company;
import org.hibernate.test.dynamicentity.ProxyHelper;
import org.hibernate.test.dynamicentity.Customer;
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,176 +0,0 @@
-// $Id: ASTQueryTranslatorTest.java 8889 2005-12-20 17:35:54Z steveebersole $
-package org.hibernate.test.hql;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests cases where the AST based QueryTranslator does not generate identical SQL.
- *
- * @author josh Dec 6, 2004 9:07:58 AM
- */
-public class ASTQueryTranslatorTest extends QueryTranslatorTestCase {
-
- public ASTQueryTranslatorTest(String x) {
- super( x );
- }
-
- public static Test suite() {
- return new TestSuite( ASTQueryTranslatorTest.class );
- }
-
- protected boolean dropAfterFailure() {
- return false;
- }
-
- // ##### TESTS THAT DON'T PASS BECAUSE THEY GENERATE DIFFERENT, POSSIBLY VALID SQL #####
-
- public void testSelectManyToOne() {
- assertTranslation("select distinct a.zoo from Animal a where a.zoo is not null");
- assertTranslation("select a.zoo from Animal a");
- }
-
- public void testSelectExpression() {
- //old qt cant handle select-clause expressions
- assertTranslation("select a.bodyWeight + m.bodyWeight from Animal a join a.mother m");
- }
-
- public void testFetchProperties() {
- //not implemented in old qt
- assertTranslation("from Animal a fetch all properties join a.offspring o fetch all properties");
- }
-
- public void testOldSyntax() {
- //generates ANSI join instead of theta join
- assertTranslation("from a in class Animal, o in elements(a.offspring), h in class Human");
- }
-
- public void testImplicitJoinInsideOutsideSubselect() {
- // new qt re-uses the joins defined by 's.other.count' path when referenced in the subquery,
- // whereas the old qt reuses only the "root table" (not the already defined join to 'other'):
- // OLD SQL :
- // select simple0_.id_ as col_0_0_
- // from Simple simple0_,
- // Simple simple1_
- // where (simple1_.count_>0
- // and simple0_.other=simple1_.id_)
- // and (simple0_.id_=some(
- // select simple2_.id_
- // from Simple simple2_,
- // Simple simple3_,
- // Simple simple4_
- // where (simple3_.count_=simple4_.count_
- // and simple2_.other=simple3_.id_
- // and simple0_.other=simple4_.id_)
- // ))
- // NEW SQL :
- // select simple0_.id_ as col_0_0_
- // from Simple simple0_,
- // Simple simple1_
- // where (simple1_.count_>0
- // and simple0_.id_=some(
- // select simple2_.id_
- // from Simple simple2_,
- // Simple simple3_
- // where (simple3_.count_=simple1_.count_
- // and simple2_.other=simple3_.id_)
- // )
- // and simple0_.other=simple1_.id_)
- assertTranslation( "from Simple s where s = some( from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0" );
- assertTranslation( "from Simple s where s.other.count > 0 and s = some( from Simple sim where sim.other.count=s.other.count )" );
- }
-
- public void testNakedPropertyRef() {
- // this is needed for ejb3 selects and bulk statements
- // Note: these all fail because the old parser did not have this
- // feature, it just "passes the tokens through" to the SQL.
- assertTranslation( "from Animal where bodyWeight = bodyWeight" );
- assertTranslation( "select bodyWeight from Animal" );
- assertTranslation( "select max(bodyWeight) from Animal" );
- }
-
- public void testNakedComponentPropertyRef() {
- // this is needed for ejb3 selects and bulk statements
- // Note: these all fail because the old parser did not have this
- // feature, it just "passes the tokens through" to the SQL.
- assertTranslation( "from Human where name.first = 'Gavin'" );
- assertTranslation( "select name from Human" );
- assertTranslation( "select upper(h.name.first) from Human as h" );
- assertTranslation( "select upper(name.first) from Human" );
- }
-
- public void testNakedMapIndex() throws Exception {
- assertTranslation( "from Zoo where mammals['dog'].description like '%black%'" );
- }
-
- public void testNakedImplicitJoins() {
- assertTranslation( "from Animal where mother.father = ?" );
- }
-
- public void testDuplicateImplicitJoinInWhere() {
- //new qt has more organized joins
- assertTranslation("from Human h where h.mother.bodyWeight>10 and h.mother.bodyWeight<10");
- }
-
- public void testWhereExpressions() {
- assertTranslation("from User u where u.userName='gavin' and u.human.name.first='Gavin'");
- //new qt has more organized joins
- assertTranslation("from User u where u.human.name.last='King' and u.human.name.first='Gavin'");
- assertTranslation("from Bar bar where bar.baz.name='josh'");
- assertTranslation("from Bar bar where bar.baz.name='josh' and not bar.baz.name='gavin'");
- }
-
- public void testImplicitJoinInSelect() {
- //slightly diff select clause, both correct
- assertTranslation("select foo.long, foo.foo from Foo foo");
- }
-
- public void testSelectStandardFunctions() throws Exception {
- //old parser throws an exception
- assertTranslation( "select current_date(), current_time(), current_timestamp() from Animal" );
- }
-
- public void testSelectClauseImplicitJoin() throws Exception {
- //the old query translator has a bug which results in the wrong return type!
- assertTranslation( "select d.owner.mother from Dog d" );
- }
-
- public void testComplexWhereExpression() throws Exception {
- // classic QT generates lots of extra parens and some extra theta joins.
- assertTranslation( "select distinct s from Simple s\n" +
- "where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2" );
- }
-
- public void testDuplicateImplicitJoin() throws Exception {
- // old qt generates an extra theta join
- assertTranslation( "from Animal an where an.mother.bodyWeight > 10 and an.mother.bodyWeight < 20" );
- }
-
- public void testKeywordClassNameAndAlias() throws Exception {
- // The old QT throws an exception, the new one doesn't, which is better
- assertTranslation( "from Order order" );
- }
-
- public void testComponent3() throws Exception {
- // The old translator generates duplicate inner joins *and* duplicate theta join clauses in the where statement in this case.
- assertTranslation( "from Dog dog where dog.owner.name.first = 'Gavin' and dog.owner.name.last='King' and dog.owner.bodyWeight<70" );
- }
-
- public void testUncorrelatedSubselectWithJoin() throws Exception {
- // The old translator generates unnecessary inner joins for the Animal subclass of zoo.mammals
- // The new one is working fine now!
- assertTranslation( "from Animal a where a in (select mam from Zoo zoo join zoo.mammals mam)" );
- }
-
- public void testFetch() throws Exception {
- //SQL is correct, new qt is not throwing an exception when it should be (minor issue)
- assertTranslation("from Customer cust left join fetch cust.billingAddress where cust.customerId='abc123'");
- }
-
- public void testImplicitJoin() throws Exception {
- //old qt generates an exception, the new one doesnt
- //this is actually invalid HQL, an implicit join on a many-valued association
- assertTranslation( "from Animal an where an.offspring.mother.bodyWeight > 10" );
- }
-
-}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/EJBQLTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -7,9 +7,7 @@
import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.hql.QueryTranslator;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.hql.antlr.HqlSqlTokenTypes;
@@ -17,7 +15,6 @@
import org.hibernate.hql.ast.HqlParser;
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.util.ASTUtil;
-import org.hibernate.test.TestCase;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/WithClauseTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,42 +1,40 @@
// $Id: WithClauseTest.java 10945 2006-12-07 14:50:42Z steve.ebersole(a)jboss.com $
package org.hibernate.test.hql;
-import org.hibernate.test.TestCase;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.HibernateException;
-import org.hibernate.QueryException;
-import org.hibernate.hql.ast.InvalidWithClauseException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.hql.ast.InvalidWithClauseException;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
/**
* Implementation of WithClauseTest.
*
* @author Steve Ebersole
*/
-public class WithClauseTest extends TestCase {
+public class WithClauseTest extends FunctionalTestCase {
public WithClauseTest(String name) {
super( name );
}
- protected String[] getMappings() {
+ public String[] getMappings() {
return new String[] { "hql/Animal.hbm.xml" };
}
public static Test suite() {
- return new TestSuite( WithClauseTest.class );
+ return new FunctionalTestClassTestSuite( WithClauseTest.class );
}
- protected void configure(Configuration cfg) {
+ public void configure(Configuration cfg) {
super.configure( cfg );
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/id/UseIdentifierRollbackTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,18 +1,19 @@
//$Id: $
package org.hibernate.test.id;
-import org.hibernate.test.TestCase;
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import junit.framework.Test;
/**
* @author Emmanuel Bernard
*/
-public class UseIdentifierRollbackTest extends TestCase {
+public class UseIdentifierRollbackTest extends FunctionalTestCase {
public UseIdentifierRollbackTest(String str) {
super(str);
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestLazyExecutable.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,16 +1,16 @@
package org.hibernate.test.instrument.cases;
-import org.hibernate.test.TestCase;
-import org.hibernate.test.instrument.cases.AbstractExecutable;
-import org.hibernate.test.instrument.domain.Owner;
-import org.hibernate.test.instrument.domain.Document;
-import org.hibernate.test.instrument.domain.Folder;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
+import junit.framework.TestCase;
+
+import org.hibernate.CacheMode;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
-import org.hibernate.CacheMode;
+import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.test.instrument.domain.Document;
+import org.hibernate.test.instrument.domain.Folder;
+import org.hibernate.test.instrument.domain.Owner;
/**
* @author Steve Ebersole
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,6 +1,5 @@
package org.hibernate.test.jpa;
-import org.hibernate.test.TestCase;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.proxy.EntityNotFoundDelegate;
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -2,34 +2,34 @@
import junit.framework.Test;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
import org.hibernate.event.LoadEvent;
import org.hibernate.event.LoadEventListener;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
+import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-import org.hibernate.test.TestCase;
/**
* @author Steve Ebersole
*/
-public class EagerKeyManyToOneTest extends TestCase {
+public class EagerKeyManyToOneTest extends FunctionalTestCase {
public EagerKeyManyToOneTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "keymanytoone/bidir/component/EagerMapping.hbm.xml" };
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( EagerKeyManyToOneTest.class );
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "keymanytoone/bidir/component/EagerMapping.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
LoadEventListener[] baseListeners = cfg.getEventListeners().getLoadEventListeners();
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/component/LazyKeyManyToOneTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -2,29 +2,29 @@
import junit.framework.Test;
-import org.hibernate.test.TestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class LazyKeyManyToOneTest extends TestCase {
+public class LazyKeyManyToOneTest extends FunctionalTestCase {
public LazyKeyManyToOneTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "keymanytoone/bidir/component/LazyMapping.hbm.xml" };
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( LazyKeyManyToOneTest.class );
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "keymanytoone/bidir/component/LazyMapping.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/keymanytoone/bidir/embedded/KeyManyToOneTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -2,29 +2,29 @@
import junit.framework.Test;
-import org.hibernate.test.TestCase;
import org.hibernate.Session;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Steve Ebersole
*/
-public class KeyManyToOneTest extends TestCase {
+public class KeyManyToOneTest extends FunctionalTestCase {
public KeyManyToOneTest(String name) {
super( name );
}
- protected String[] getMappings() {
- return new String[] { "keymanytoone/bidir/embedded/Mapping.hbm.xml" };
- }
-
public static Test suite() {
return new FunctionalTestClassTestSuite( KeyManyToOneTest.class );
}
- protected void configure(Configuration cfg) {
+ public String[] getMappings() {
+ return new String[] { "keymanytoone/bidir/embedded/Mapping.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -8,19 +8,33 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
* @author Gavin King
*/
-public class InstrumentCacheTest extends FunctionalTestCase {
+public class InstrumentCacheTest extends DatabaseSpecificFunctionalTestCase {
public InstrumentCacheTest(String str) {
super(str);
}
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( InstrumentCacheTest.class );
+ }
+
+ private boolean isRunnable() {
+ // skip this test if document is not instrumented/enhanced
+ return FieldInterceptionHelper.isInstrumented( new Document() );
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return isRunnable();
+ }
+
public String[] getMappings() {
return new String[] { "lazycache/Documents.hbm.xml" };
}
@@ -33,16 +47,11 @@
return false;
}
- public static Test suite() {
- return new FunctionalTestClassTestSuite( InstrumentCacheTest.class );
- }
-
- public static boolean isRunnable() {
- // TODO : this could be handled via appliesTo()...
- return FieldInterceptionHelper.isInstrumented( new Document() );
- }
-
public void testInitFromCache() {
+ if ( !isRunnable() ) {
+ reportSkip( "classes not instrumented", "instrumentation tests" );
+ return;
+ }
Session s;
Transaction tx;
@@ -82,5 +91,49 @@
s.close();
}
+ public void testInitFromCache2() {
+ if ( !isRunnable() ) {
+ reportSkip( "classes not instrumented", "instrumentation tests" );
+ return;
+ }
+ Session s;
+ Transaction tx;
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
+ tx.commit();
+ s.close();
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ s.createQuery("from Document fetch all properties").uniqueResult();
+ tx.commit();
+ s.close();
+
+ getSessions().getStatistics().clear();
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ Document d = (Document) s.createCriteria(Document.class).uniqueResult();
+ assertFalse( Hibernate.isPropertyInitialized(d, "text") );
+ assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
+ assertEquals( "Hibernate is....", d.getText() );
+ assertTrue( Hibernate.isPropertyInitialized(d, "text") );
+ assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
+ tx.commit();
+ s.close();
+
+ assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );
+
+ s = getSessions().openSession();
+ tx = s.beginTransaction();
+ d = (Document) s.get(Document.class, d.getId());
+ assertTrue( Hibernate.isPropertyInitialized(d, "text") );
+ assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
+ tx.commit();
+ s.close();
+ }
+
}
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest2.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,81 +0,0 @@
-//$Id: InstrumentCacheTest2.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.com $
-package org.hibernate.test.lazycache;
-
-import junit.framework.Test;
-
-import org.hibernate.Hibernate;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * @author Gavin King
- */
-public class InstrumentCacheTest2 extends FunctionalTestCase {
-
- public InstrumentCacheTest2(String str) {
- super(str);
- }
-
- public String[] getMappings() {
- return new String[] { "lazycache/Documents.hbm.xml" };
- }
-
- public void configure(Configuration cfg) {
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- }
-
- public static Test suite() {
- return new FunctionalTestClassTestSuite( InstrumentCacheTest2.class );
- }
-
- public static boolean isRunnable() {
- return FieldInterceptionHelper.isInstrumented( new Document() );
- }
-
- public void testInitFromCache() {
- Session s;
- Transaction tx;
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
- tx.commit();
- s.close();
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- s.createQuery("from Document fetch all properties").uniqueResult();
- tx.commit();
- s.close();
-
- getSessions().getStatistics().clear();
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- Document d = (Document) s.createCriteria(Document.class).uniqueResult();
- assertFalse( Hibernate.isPropertyInitialized(d, "text") );
- assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
- assertEquals( "Hibernate is....", d.getText() );
- assertTrue( Hibernate.isPropertyInitialized(d, "text") );
- assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
- tx.commit();
- s.close();
-
- assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );
-
- s = getSessions().openSession();
- tx = s.beginTransaction();
- d = (Document) s.get(Document.class, d.getId());
- assertTrue( Hibernate.isPropertyInitialized(d, "text") );
- assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
- tx.commit();
- s.close();
- }
-
-}
-
Modified: trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
===================================================================
--- trunk/Hibernate3/testsuite/src/test/resources/log4j.properties 2007-05-26 07:34:00 UTC (rev 11574)
+++ trunk/Hibernate3/testsuite/src/test/resources/log4j.properties 2007-05-26 07:34:56 UTC (rev 11575)
@@ -1,41 +1,9 @@
-### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
-### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
-log4j.logger.org.hibernate=info
-#log4j.logger.org.hibernate=debug
-
-### log HQL query parser activity
-#log4j.logger.org.hibernate.hql.ast.AST=debug
-
-### log just the SQL
-#log4j.logger.org.hibernate.SQL=debug
-
-### log JDBC bind parameters ###
-log4j.logger.org.hibernate.type=info
-#log4j.logger.org.hibernate.type=debug
-
-### log schema export/update ###
-log4j.logger.org.hibernate.tool.hbm2ddl=debug
-
-### log HQL parse trees
-#log4j.logger.org.hibernate.hql=debug
-
-### log cache activity ###
-#log4j.logger.org.hibernate.cache=debug
-
-### log transaction activity
-#log4j.logger.org.hibernate.transaction=debug
-
-### log JDBC resource acquisition
-#log4j.logger.org.hibernate.jdbc=debug
-
-### enable the following line if you want to track down connection ###
-### leakages when using DriverManagerConnectionProvider ###
-#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
+log4j.logger.org.hibernate.test=info
\ No newline at end of file
Copied: trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java (from rev 11563, trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/hql/ASTQueryTranslatorTest.java)
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/hql/ASTQueryTranslatorTest.java 2007-05-26 07:34:56 UTC (rev 11575)
@@ -0,0 +1,176 @@
+// $Id: ASTQueryTranslatorTest.java 8889 2005-12-20 17:35:54Z steveebersole $
+package org.hibernate.test.hql;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests cases where the AST based QueryTranslator does not generate identical SQL.
+ *
+ * @author josh Dec 6, 2004 9:07:58 AM
+ */
+public class ASTQueryTranslatorTest extends QueryTranslatorTestCase {
+
+ public ASTQueryTranslatorTest(String x) {
+ super( x );
+ }
+
+ public static Test suite() {
+ return new TestSuite( ASTQueryTranslatorTest.class );
+ }
+
+ protected boolean dropAfterFailure() {
+ return false;
+ }
+
+ // ##### TESTS THAT DON'T PASS BECAUSE THEY GENERATE DIFFERENT, POSSIBLY VALID SQL #####
+
+ public void testSelectManyToOne() {
+ assertTranslation("select distinct a.zoo from Animal a where a.zoo is not null");
+ assertTranslation("select a.zoo from Animal a");
+ }
+
+ public void testSelectExpression() {
+ //old qt cant handle select-clause expressions
+ assertTranslation("select a.bodyWeight + m.bodyWeight from Animal a join a.mother m");
+ }
+
+ public void testFetchProperties() {
+ //not implemented in old qt
+ assertTranslation("from Animal a fetch all properties join a.offspring o fetch all properties");
+ }
+
+ public void testOldSyntax() {
+ //generates ANSI join instead of theta join
+ assertTranslation("from a in class Animal, o in elements(a.offspring), h in class Human");
+ }
+
+ public void testImplicitJoinInsideOutsideSubselect() {
+ // new qt re-uses the joins defined by 's.other.count' path when referenced in the subquery,
+ // whereas the old qt reuses only the "root table" (not the already defined join to 'other'):
+ // OLD SQL :
+ // select simple0_.id_ as col_0_0_
+ // from Simple simple0_,
+ // Simple simple1_
+ // where (simple1_.count_>0
+ // and simple0_.other=simple1_.id_)
+ // and (simple0_.id_=some(
+ // select simple2_.id_
+ // from Simple simple2_,
+ // Simple simple3_,
+ // Simple simple4_
+ // where (simple3_.count_=simple4_.count_
+ // and simple2_.other=simple3_.id_
+ // and simple0_.other=simple4_.id_)
+ // ))
+ // NEW SQL :
+ // select simple0_.id_ as col_0_0_
+ // from Simple simple0_,
+ // Simple simple1_
+ // where (simple1_.count_>0
+ // and simple0_.id_=some(
+ // select simple2_.id_
+ // from Simple simple2_,
+ // Simple simple3_
+ // where (simple3_.count_=simple1_.count_
+ // and simple2_.other=simple3_.id_)
+ // )
+ // and simple0_.other=simple1_.id_)
+ assertTranslation( "from Simple s where s = some( from Simple sim where sim.other.count=s.other.count ) and s.other.count > 0" );
+ assertTranslation( "from Simple s where s.other.count > 0 and s = some( from Simple sim where sim.other.count=s.other.count )" );
+ }
+
+ public void testNakedPropertyRef() {
+ // this is needed for ejb3 selects and bulk statements
+ // Note: these all fail because the old parser did not have this
+ // feature, it just "passes the tokens through" to the SQL.
+ assertTranslation( "from Animal where bodyWeight = bodyWeight" );
+ assertTranslation( "select bodyWeight from Animal" );
+ assertTranslation( "select max(bodyWeight) from Animal" );
+ }
+
+ public void testNakedComponentPropertyRef() {
+ // this is needed for ejb3 selects and bulk statements
+ // Note: these all fail because the old parser did not have this
+ // feature, it just "passes the tokens through" to the SQL.
+ assertTranslation( "from Human where name.first = 'Gavin'" );
+ assertTranslation( "select name from Human" );
+ assertTranslation( "select upper(h.name.first) from Human as h" );
+ assertTranslation( "select upper(name.first) from Human" );
+ }
+
+ public void testNakedMapIndex() throws Exception {
+ assertTranslation( "from Zoo where mammals['dog'].description like '%black%'" );
+ }
+
+ public void testNakedImplicitJoins() {
+ assertTranslation( "from Animal where mother.father = ?" );
+ }
+
+ public void testDuplicateImplicitJoinInWhere() {
+ //new qt has more organized joins
+ assertTranslation("from Human h where h.mother.bodyWeight>10 and h.mother.bodyWeight<10");
+ }
+
+ public void testWhereExpressions() {
+ assertTranslation("from User u where u.userName='gavin' and u.human.name.first='Gavin'");
+ //new qt has more organized joins
+ assertTranslation("from User u where u.human.name.last='King' and u.human.name.first='Gavin'");
+ assertTranslation("from Bar bar where bar.baz.name='josh'");
+ assertTranslation("from Bar bar where bar.baz.name='josh' and not bar.baz.name='gavin'");
+ }
+
+ public void testImplicitJoinInSelect() {
+ //slightly diff select clause, both correct
+ assertTranslation("select foo.long, foo.foo from Foo foo");
+ }
+
+ public void testSelectStandardFunctions() throws Exception {
+ //old parser throws an exception
+ assertTranslation( "select current_date(), current_time(), current_timestamp() from Animal" );
+ }
+
+ public void testSelectClauseImplicitJoin() throws Exception {
+ //the old query translator has a bug which results in the wrong return type!
+ assertTranslation( "select d.owner.mother from Dog d" );
+ }
+
+ public void testComplexWhereExpression() throws Exception {
+ // classic QT generates lots of extra parens and some extra theta joins.
+ assertTranslation( "select distinct s from Simple s\n" +
+ "where ( ( s.other.count + 3 ) = (15*2)/2 and s.count = 69) or ( ( s.other.count + 2 ) / 7 ) = 2" );
+ }
+
+ public void testDuplicateImplicitJoin() throws Exception {
+ // old qt generates an extra theta join
+ assertTranslation( "from Animal an where an.mother.bodyWeight > 10 and an.mother.bodyWeight < 20" );
+ }
+
+ public void testKeywordClassNameAndAlias() throws Exception {
+ // The old QT throws an exception, the new one doesn't, which is better
+ assertTranslation( "from Order order" );
+ }
+
+ public void testComponent3() throws Exception {
+ // The old translator generates duplicate inner joins *and* duplicate theta join clauses in the where statement in this case.
+ assertTranslation( "from Dog dog where dog.owner.name.first = 'Gavin' and dog.owner.name.last='King' and dog.owner.bodyWeight<70" );
+ }
+
+ public void testUncorrelatedSubselectWithJoin() throws Exception {
+ // The old translator generates unnecessary inner joins for the Animal subclass of zoo.mammals
+ // The new one is working fine now!
+ assertTranslation( "from Animal a where a in (select mam from Zoo zoo join zoo.mammals mam)" );
+ }
+
+ public void testFetch() throws Exception {
+ //SQL is correct, new qt is not throwing an exception when it should be (minor issue)
+ assertTranslation("from Customer cust left join fetch cust.billingAddress where cust.customerId='abc123'");
+ }
+
+ public void testImplicitJoin() throws Exception {
+ //old qt generates an exception, the new one doesnt
+ //this is actually invalid HQL, an implicit join on a many-valued association
+ assertTranslation( "from Animal an where an.offspring.mother.bodyWeight > 10" );
+ }
+
+}
17 years, 6 months
Hibernate SVN: r11574 - trunk/Hibernate3/testing/src/main/java/org/hibernate/junit/functional.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 03:34:00 -0400 (Sat, 26 May 2007)
New Revision: 11574
Modified:
trunk/Hibernate3/testing/src/main/java/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
Log:
minor
Modified: trunk/Hibernate3/testing/src/main/java/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
===================================================================
--- trunk/Hibernate3/testing/src/main/java/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2007-05-26 06:37:10 UTC (rev 11573)
+++ trunk/Hibernate3/testing/src/main/java/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2007-05-26 07:34:00 UTC (rev 11574)
@@ -33,14 +33,6 @@
this( testClass, testClass.getName() );
}
- /**
- * Constructor form used during {@link org.hibernate.test.AllTests} filtering...
- *
- * @param name The name.
- */
- private FunctionalTestClassTestSuite(String name) {
- super( name );
- }
public void addTest(Test test) {
log.trace( "adding test [" + test + "]" );
17 years, 6 months
Hibernate SVN: r11573 - in trunk/Hibernate3/testsuite: src/test and 11 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 02:37:10 -0400 (Sat, 26 May 2007)
New Revision: 11573
Added:
trunk/Hibernate3/testsuite/src/test/perf/
trunk/Hibernate3/testsuite/src/test/perf/org/
trunk/Hibernate3/testsuite/src/test/profile/
trunk/Hibernate3/testsuite/src/test/profile/hsqldb/
trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties
trunk/Hibernate3/testsuite/src/test/resources/
trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml
trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
trunk/Hibernate3/testsuite/src/test/unmaintained/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java
Removed:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/tool/
Modified:
trunk/Hibernate3/testsuite/pom.xml
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
Log:
a little better on the test suite
Modified: trunk/Hibernate3/testsuite/pom.xml
===================================================================
--- trunk/Hibernate3/testsuite/pom.xml 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/pom.xml 2007-05-26 06:37:10 UTC (rev 11573)
@@ -43,6 +43,89 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-swarmcache</artifactId>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.11</version>
+ </dependency>
+ <!-- these are optional on core... :( -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-attrs</artifactId>
+ <version>1.5.3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>hibernate.test.validatefailureexpected</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>hsqldb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/profile/hsqldb</directory>
+ </testResource>
+ </testResources>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
</project>
\ No newline at end of file
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -1,14 +1,14 @@
-package org.hibernate.junit;
+package org.hibernate.test;
-import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
-import junit.framework.TestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
+import junit.framework.TestSuite;
-import org.hibernate.test.AllTests;
+import org.hibernate.junit.TestSuiteVisitor;
/**
* A simple class to collect the names of "failure expected" tests...
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -1,64 +0,0 @@
-package org.hibernate.test;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.io.File;
-
-import org.apache.tools.ant.types.selectors.FileSelector;
-import org.apache.tools.ant.BuildException;
-
-import org.hibernate.junit.TestSuiteVisitor;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * A custom Ant FileSelector used to limit the tests run from the Ant
- * build script to only those defined in the {@link org.hibernate.test.AllTests} suite.
- * <p/>
- * {@link org.hibernate.test.AllTests} is used/maintained by the developers to easily
- * run the test suite in all IDEs. It represents all the tests
- * which should actually be run and included in test results.
- *
- * @author Steve Ebersole
- */
-public class TestSelector implements FileSelector {
-
- private final Set allTestClassNames = new HashSet();
-
- public TestSelector() {
- TestSuiteVisitor.Handler handler = new TestSuiteVisitor.Handler() {
- public void handleTestCase(Test test) {
- allTestClassNames.add( test.getClass().getName() );
- }
- public void startingTestSuite(TestSuite suite) {}
- public void completedTestSuite(TestSuite suite) {}
- };
- TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
- visitor.visit( ( TestSuite ) AllTests.suite() );
- }
-
-
- // FileSelector impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean isSelected(File dir, String fileFromDir, File fullFile) throws BuildException {
- String correspondingClassName = determineClassName( fileFromDir );
- return allTestClassNames.contains( correspondingClassName );
- }
-
- private String determineClassName(String file) {
- if ( file.endsWith( ".class" ) ) {
- file = file.substring( 0, file.length() - 6 );
- }
- else if ( file.endsWith( ".java" ) ) {
- file = file.substring( 0, file.length() - 5 );
- }
- else {
- return null;
- }
- file = file.replace( '\\', '.' );
- file = file.replace( '/', '.' );
- return file;
- }
-
-}
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -83,7 +83,7 @@
public void testLoadingAndSerializationOfConfiguration() throws HibernateException, FileNotFoundException, IOException, ClassNotFoundException {
- String prefix = "./test/org/hibernate/test/";
+ String prefix = "./src/test/java/org/hibernate/test/";
try {
// first time
System.err.println("###FIRST SAVELOAD###");
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -1,92 +0,0 @@
-//$Id: NewPerformanceTest.java 5718 2005-02-13 23:01:34Z oneovthafew $
-package org.hibernate.test.legacy;
-
-import java.io.Serializable;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.hibernate.classic.Session;
-import org.hibernate.test.TestCase;
-
-public class NewPerformanceTest extends TestCase {
-
- public NewPerformanceTest(String arg0) {
- super(arg0);
- }
-
- public void testPerformance() throws Exception {
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- Session s = openSession();
- prepare(s, simples, ids, n);
- s.close();
-
- long find = 0;
- long flush = 0;
-
- for ( int i=0; i<100; i++ ) {
-
- s = openSession();
- long time = System.currentTimeMillis();
- List list = s.createQuery("from Simple s where not s.name='osama bin laden' and s.other is null").list();
- find += System.currentTimeMillis() - time;
- assertTrue( list.size()==n );
- time = System.currentTimeMillis();
- s.flush();
- flush += System.currentTimeMillis() - time;
- time = System.currentTimeMillis();
- s.connection().commit();
- find += System.currentTimeMillis() - time;
- s.close();
-
- }
-
- System.out.println( "Objects: " + n + " - find(): " + find + "ms / flush(): " + flush + "ms / Ratio: " + ( (float) flush )/find );
- System.out.println( "Objects: " + n + " flush time per object: " + flush / 100.0 / n );
- System.out.println( "Objects: " + n + " load time per object: " + find / 100.0 / n );
- s = openSession();
- delete(s);
- s.close();
-
- }
- }
-
- private void prepare(Session s, Simple[] simples, Serializable[] ids, int N) throws Exception {
- for ( int i=0; i<N; i++ ) {
- s.save( simples[i], ids[i] );
- }
- s.flush();
- s.connection().commit();
- }
-
- private void delete(Session s) throws Exception {
- s.delete("from Simple s");
- s.flush();
- s.connection().commit();
- }
-
- public String[] getMappings() {
- return new String[] { "legacy/Simple.hbm.xml" };
- }
-
- public static Test suite() throws Exception {
- return new TestSuite(NewPerformanceTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
-}
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -1,402 +0,0 @@
-//$Id: NewerPerformanceTest.java 4599 2004-09-26 05:18:27Z oneovthafew $
-package org.hibernate.test.legacy;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.hibernate.classic.Session;
-import org.hibernate.cfg.Environment;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.test.TestCase;
-
-public class NewerPerformanceTest extends TestCase {
-
- public NewerPerformanceTest(String arg0) {
- super(arg0);
- }
-
- public void testMany() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );
-
- long hiber=0;
- long jdbc=0;
-
- for ( int n=0; n<20; n++ ) {
-
- Session s = openSession();
- s.delete("from Simple");
- s.flush();
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
- //allow cache to settle
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- int N=30;
-
- long time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h2");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j2" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- }
-
- System.out.println( "Hibernate: " + hiber + "ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );
-
- cp.close();
- System.gc();
- }
-
- public void testSimultaneous() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Session s = openSession();
- s.delete("from Simple");
- s.flush();
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
- //allow cache to settle
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber + "ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );
-
- }
-
- cp.close();
- System.gc();
- }
-
- public void testHibernateOnly() throws Exception {
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Session s = openSession();
- Simple[] simples = new Simple[n];
- s.delete("from Simple");
- s.flush();
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
- //Now do timings
-
- s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber );
-
- }
-
- System.gc();
- }
-
- public void testJdbcOnly() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Session s = openSession();
- Simple[] simples = new Simple[n];
- s.delete("from Simple");
- s.flush();
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
-
- //Now do timings
-
- Connection c = cp.getConnection();
- long time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );
-
- }
-
- cp.close();
- System.gc();
- }
-
- /*private void hibernate(Session s, Simple[] simples, Serializable[] ids, int N, String runname) throws Exception {
- for ( int i=0; i<N; i++ ) {
- s.get( Simple.class, ids[i] );
- //s.find("from Simple s where s.id = ?", ids[i], Hibernate.LONG);
- }
- //s.flush();
- s.connection().commit();
- }
-
- private void directJDBC(Connection c, Simple[] simples, Serializable[] ids, int N, String runname) throws SQLException {
-
- for ( int i=0; i<N; i++ ) {
- PreparedStatement select = c.prepareStatement("SELECT s.id_, s.name, s.address, s.count_, s.date_, s.pay, s.other FROM Simple s where s.id_=?");
- select.setLong( 1, ( (Long) ids[i] ).longValue() );
- ResultSet rs = select.executeQuery();
- rs.next();
- /*new Long( rs.getLong(1) );
- rs.getString(2);
- rs.getString(3);
- rs.getInt(4);
- rs.getDate(5);
- rs.getFloat(6);
- rs.getLong(7);*/
- /*Simple s = new Simple();
- new Long( rs.getLong("id_") ); rs.wasNull();
- s.setName( rs.getString("name") ); rs.wasNull();
- s.setAddress( rs.getString("address") ); rs.wasNull();
- s.setCount( rs.getInt("count_") ); rs.wasNull();
- s.setDate( rs.getTimestamp("date_") ); rs.wasNull();
- s.setPay( new Float( rs.getFloat("pay") ) ); rs.wasNull();
- rs.getLong("other"); rs.wasNull(); s.setOther(null);
- rs.close();
- select.close();
- }
- c.commit();
- }*/
-
- private void hibernate(Session s, Simple[] simples, Serializable[] ids, int N, String runname) throws Exception {
- s.createQuery("from Simple s").list();
- s.connection().commit();
- }
-
- private void directJDBC(Connection c, Simple[] simples, Serializable[] ids, int N, String runname) throws SQLException {
- List result=new ArrayList();
- PreparedStatement select = c.prepareStatement("SELECT s.id_ as id_, s.name as name, s.address as address, s.count_ as count_, s.date_ as date_, s.pay as pay, s.other as other FROM Simple s");
- ResultSet rs = select.executeQuery();
- while ( rs.next() ) {
- /*new Long( rs.getLong(1) );
- rs.getString(2);
- rs.getString(3);
- rs.getInt(4);
- rs.getDate(5);
- rs.getFloat(6);
- rs.getLong(7);*/
- Simple s = new Simple();
- new Long( rs.getLong("id_") ); rs.wasNull();
- s.setName( rs.getString("name") ); rs.wasNull();
- s.setAddress( rs.getString("address") ); rs.wasNull();
- s.setCount( rs.getInt("count_") ); rs.wasNull();
- s.setDate( rs.getTimestamp("date_") ); rs.wasNull();
- s.setPay( new Float( rs.getFloat("pay") ) ); rs.wasNull();
- rs.getLong("other"); rs.wasNull(); s.setOther(null);
- result.add(s);
- }
- rs.close();
- select.close();
- c.commit();
- }
-
- public String[] getMappings() {
- return new String[] { "legacy/Simple.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(NewerPerformanceTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
-}
-
-
-
-
-
-
-
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -1,356 +0,0 @@
-//$Id: PerformanceTest.java 6900 2005-05-25 01:24:22Z oneovthafew $
-package org.hibernate.test.legacy;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.hibernate.classic.Session;
-import org.hibernate.cfg.Environment;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.test.TestCase;
-
-public class PerformanceTest extends TestCase {
-
- public PerformanceTest(String arg0) {
- super(arg0);
- }
-
- public void testMany() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );
-
- long hiber=0;
- long jdbc=0;
-
- for ( int n=0; n<20; n++ ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //allow cache to settle
-
- Session s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- int N=30;
-
- long time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h2");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j2" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- }
-
- System.out.println( "Hibernate: " + hiber + "ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );
-
- cp.close();
- System.gc();
- }
-
- public void testSimultaneous() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //allow cache to settle
-
- Session s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber + "ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );
-
- }
-
- cp.close();
- System.gc();
- }
-
- public void testHibernateOnly() throws Exception {
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //Now do timings
-
- Session s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber );
-
- }
-
- System.gc();
- }
-
- public void testJdbcOnly() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //Now do timings
-
- Connection c = cp.getConnection();
- long time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );
-
- }
-
- cp.close();
- System.gc();
- }
-
- private void hibernate(Session s, Simple[] simples, Serializable[] ids, int N, String runname) throws Exception {
- for ( int i=0; i<N; i++ ) {
- s.save( simples[i], ids[i] );
- }
- for ( int i=0; i<N; i++ ) {
- simples[0].setName("A Different Name!" + i + N + runname);
- }
- //s.flush();
- // the results of this test are highly dependent upon
- // how many times we flush!
- assertTrue( "assertion", s.delete("from Simple s")==N );
- s.flush();
- s.connection().commit();
- }
-
- private void directJDBC(Connection c, Simple[] simples, Serializable[] ids, int N, String runname) throws SQLException {
-
- PreparedStatement insert = c.prepareStatement("insert into Simple ( name, address, count_, date_, other, id_ ) values ( ?, ?, ?, ?, ?, ? )");
- PreparedStatement delete = c.prepareStatement("delete from Simple where id_ = ?");
- PreparedStatement select = c.prepareStatement("SELECT s.id_, s.name, s.address, s.count_, s.date_, s.other FROM Simple s");
- PreparedStatement update = c.prepareStatement("update Simple set name = ?, address = ?, count_ = ?, date_ = ?, other = ? where id_ = ?");
- for ( int i=0; i<N; i++ ) {
- insert.setString(1, simples[i].getName() );
- insert.setString(2, simples[i].getAddress() );
- insert.setInt(3, simples[i].getCount() );
- insert.setDate( 4, (java.sql.Date) simples[i].getDate() );
- insert.setNull(5, Types.BIGINT);
- insert.setLong( 6, ( (Long) ids[i] ).longValue() );
- insert.executeUpdate();
- }
- insert.close();
- for ( int i=0; i<N; i++ ) {
- update.setString(1, "A Different Name!" + i + N + runname );
- update.setString(2, simples[i].getAddress() );
- update.setInt(3, simples[i].getCount() );
- update.setDate( 4, (java.sql.Date) simples[i].getDate() );
- update.setNull(5, Types.BIGINT);
- update.setLong( 6, ( (Long) ids[i] ).longValue() );
- update.executeUpdate();
- }
- update.close();
- java.sql.ResultSet rs = select.executeQuery();
- Long[] keys = new Long[N];
- int j=0;
- while ( rs.next() ) {
- keys[j++] = new Long( rs.getLong(1) );
- rs.getString(2);
- rs.getString(3);
- rs.getInt(4);
- rs.getDate(5);
- rs.getLong(6);
- }
- rs.close();
- select.close();
- for ( int i=0; i<N; i++ ) {
- delete.setLong(1, keys[i].longValue() );
- delete.executeUpdate();
- }
- delete.close();
- c.commit();
- }
-
- public String[] getMappings() {
- return new String[] { "legacy/Simple.hbm.xml" };
- }
-
- public static Test suite() throws Exception {
- return new TestSuite(PerformanceTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-}
Added: trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties
===================================================================
--- trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties 2007-05-26 06:37:10 UTC (rev 11573)
@@ -0,0 +1,19 @@
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.username sa
+hibernate.connection.password
+hibernate.connection.url jdbc:hsqldb:target/test/db/hsqldb/hibernate
+
+hibernate.connection.pool_size 1
+
+hibernate.jdbc.batch_versioned_data true
+hibernate.jdbc.use_streams_for_binary true
+
+hibernate.format_sql true
+
+hibernate.max_fetch_depth 1
+
+hibernate.cache.region_prefix hibernate.test
+hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
+
+hibernate.query.substitutions yes 'Y', no 'N'
\ No newline at end of file
Added: trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml
===================================================================
--- trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml 2007-05-26 06:37:10 UTC (rev 11573)
@@ -0,0 +1,8 @@
+<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+ <session-factory name="foo">
+ <property name="show_sql">true</property>
+ <mapping resource="org/hibernate/test/legacy/Simple.hbm.xml"/>
+ <class-cache class="org.hibernate.test.legacy.Simple" region="Simple" usage="read-write"/>
+ </session-factory>
+</hibernate-configuration>
\ No newline at end of file
Copied: trunk/Hibernate3/testsuite/src/test/resources/log4j.properties (from rev 11570, trunk/Hibernate3/documentation/tutorial/src/main/resources/log4j.properties)
===================================================================
--- trunk/Hibernate3/testsuite/src/test/resources/log4j.properties (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/resources/log4j.properties 2007-05-26 06:37:10 UTC (rev 11573)
@@ -0,0 +1,41 @@
+### direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+### set log levels - for more verbose logging change 'info' to 'debug' ###
+
+log4j.rootLogger=warn, stdout
+
+log4j.logger.org.hibernate=info
+#log4j.logger.org.hibernate=debug
+
+### log HQL query parser activity
+#log4j.logger.org.hibernate.hql.ast.AST=debug
+
+### log just the SQL
+#log4j.logger.org.hibernate.SQL=debug
+
+### log JDBC bind parameters ###
+log4j.logger.org.hibernate.type=info
+#log4j.logger.org.hibernate.type=debug
+
+### log schema export/update ###
+log4j.logger.org.hibernate.tool.hbm2ddl=debug
+
+### log HQL parse trees
+#log4j.logger.org.hibernate.hql=debug
+
+### log cache activity ###
+#log4j.logger.org.hibernate.cache=debug
+
+### log transaction activity
+#log4j.logger.org.hibernate.transaction=debug
+
+### log JDBC resource acquisition
+#log4j.logger.org.hibernate.jdbc=debug
+
+### enable the following line if you want to track down connection ###
+### leakages when using DriverManagerConnectionProvider ###
+#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
Added: trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml 2007-05-26 06:37:10 UTC (rev 11573)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.tool">
+ <class name="Team" table="`Team`">
+ <id name="id" column="`iD`">
+ <generator class="native">
+ <param name="sequence">TEAM_SEQ</param>
+ </generator>
+ </id>
+ <property name="name"/>
+ </class>
+
+ <class entity-name="OtherTeam" name="Team" table="TEAM">
+ <id name="id" column="id">
+ <generator class="native">
+ <param name="sequence">TEAM_SEQ</param>
+ </generator>
+ </id>
+ <property name="name" column="xname"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -0,0 +1,20 @@
+package org.hibernate.test.tool;
+
+
+public class Team {
+ 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: trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java (rev 0)
+++ trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java 2007-05-26 06:37:10 UTC (rev 11573)
@@ -0,0 +1,226 @@
+package org.hibernate.test.tool;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.SQLException;
+
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.hibernate.tool.hbm2ddl.SchemaValidator;
+
+/**
+ * @author Anthony
+ *
+ * Basic smoke test for schemaupdate/validator.
+ * Dependent on schemas, and probably also HQLDB - Not possible to have in the global test suite at the moment.
+ *
+ * WARNING, if you want this test to work, you need to define a default schema = SB
+ * in hibernate global configuration.
+ * This schema should not be the same at the default db user schema and should come after the users schema alphabetically.
+ *
+ */
+public class TestSchemaTools extends DatabaseSpecificFunctionalTestCase {
+
+ public TestSchemaTools(String name) {
+ super( name );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "tool/Team.hbm.xml" };
+ }
+
+ public boolean createSchema() {
+ return false;
+ }
+
+ public void afterSessionFactoryBuilt(SessionFactoryImplementor sfi) {
+ super.afterSessionFactoryBuilt( sfi );
+ Session session = null;
+ try {
+ session = sfi.openSession();
+ Statement stat = session.connection().createStatement();
+ stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
+ stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
+ stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER) ");
+ stat.close();
+ }
+ catch ( SQLException e ) {
+ throw new RuntimeException( "could not prepare additional schemas" );
+ }
+ finally {
+ if ( session != null ) {
+ try {
+ session.close();
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+ }
+
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
+ }
+
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof HSQLDialect;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TestSchemaTools.class );
+ }
+
+ public void testSchemaTools() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
+
+ // update schema
+ SchemaUpdate su = new SchemaUpdate(getCfg());
+ su.execute(true,true);
+
+ // we can run schema validation. Note that in the setUp method a *wrong* table
+ // has been created with different column names
+ // if schema validator chooses the bad db schema, then the testcase will fail (exception)
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public void testSchemaToolsNonQuote() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
+
+ // update schema
+ SchemaUpdate su = new SchemaUpdate(getCfg());
+ su.execute(true,true);
+
+ // we can run schema validation. Note that in the setUp method a *wrong* table
+ // has been created with different column names
+ // if schema validator chooses the bad db schema, then the testcase will fail (exception)
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+ public void testFailingQuoteValidation() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
+
+ // update schema
+ //SchemaUpdate su = new SchemaUpdate(getCfg());
+ //su.execute(true,true);
+
+ try {
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+ fail("should fail since we mutated the current schema.");
+ } catch(HibernateException he) {
+
+ }
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public void testFailingNonQuoteValidation() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
+
+ // update schema
+ //SchemaUpdate su = new SchemaUpdate(getCfg());
+ //su.execute(true,true);
+
+ try {
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+ fail("should fail since we mutated the current schema.");
+ } catch(HibernateException he) {
+
+ }
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+}
17 years, 6 months
Hibernate SVN: r11572 - trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 01:19:56 -0400 (Sat, 26 May 2007)
New Revision: 11572
Modified:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Log:
fixing test because of split
Modified: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java 2007-05-26 05:19:34 UTC (rev 11571)
+++ trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java 2007-05-26 05:19:56 UTC (rev 11572)
@@ -58,7 +58,6 @@
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.jmx.HibernateService;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.mapping.RootClass;
import org.hibernate.proxy.HibernateProxy;
@@ -4636,18 +4635,6 @@
s.close();
}
- public void testService() throws Exception {
- HibernateService hs = new HibernateService();
- hs.setJndiName("SessionFactory");
- hs.setMapResources("net/sf/hibernate/test/Simple.hbm.xml, net/sf/hibernate/test/Blobber.hbm.xml");
- hs.setShowSqlEnabled("true");
- hs.start();
- hs.stop();
- hs.setProperty("foo", "bar");
- hs.start();
- hs.stop();
- }
-
public void testPSCache() throws Exception {
Session s = openSession();
Transaction txn = s.beginTransaction();
17 years, 6 months
Hibernate SVN: r11571 - in trunk/Hibernate3/jmx/src: test and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 01:19:34 -0400 (Sat, 26 May 2007)
New Revision: 11571
Added:
trunk/Hibernate3/jmx/src/test/
trunk/Hibernate3/jmx/src/test/java/
trunk/Hibernate3/jmx/src/test/java/org/
trunk/Hibernate3/jmx/src/test/java/org/hibernate/
trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/
trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.hbm.xml
trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.java
trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/TrivialTest.java
Log:
fixing test because of split
Added: trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.hbm.xml
===================================================================
--- trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.hbm.xml (rev 0)
+++ trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.hbm.xml 2007-05-26 05:19:34 UTC (rev 11571)
@@ -0,0 +1,15 @@
+<?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>
+
+ <class name="org.hibernate.jmx.Entity">
+ <id name="id" type="long" column="id_">
+ <generator class="assigned"/>
+ </id>
+ <property name="name"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.java
===================================================================
--- trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.java (rev 0)
+++ trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/Entity.java 2007-05-26 05:19:34 UTC (rev 11571)
@@ -0,0 +1,27 @@
+package org.hibernate.jmx;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Entity {
+ 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: trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/TrivialTest.java
===================================================================
--- trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/TrivialTest.java (rev 0)
+++ trunk/Hibernate3/jmx/src/test/java/org/hibernate/jmx/TrivialTest.java 2007-05-26 05:19:34 UTC (rev 11571)
@@ -0,0 +1,30 @@
+package org.hibernate.jmx;
+
+/**
+ * Test copied over from o.h.t.legacy.FooBarTest
+ *
+ * @author Steve Ebersole
+ */
+public class TrivialTest {
+ public void testService() throws Exception {
+ HibernateService hs = new HibernateService();
+ hs.setJndiName( "SessionFactory" );
+ hs.setMapResources( "org/hibernate/jmx/Entity.hbm.xml" );
+ hs.setShowSqlEnabled( "true" );
+ hs.start();
+ hs.stop();
+ hs.setProperty( "foo", "bar" );
+ hs.start();
+ hs.stop();
+ try {
+ hs.setMapResources( "non-existent" );
+ hs.start();
+ }
+ catch( Throwable t ) {
+ // expected behavior
+ }
+ finally {
+ hs.stop();
+ }
+ }
+}
17 years, 6 months
Hibernate SVN: r11570 - in trunk/Hibernate3/documentation/tutorial: src/main/java and 12 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 00:50:07 -0400 (Sat, 26 May 2007)
New Revision: 11570
Added:
trunk/Hibernate3/documentation/tutorial/src/main/java/org/
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Event.java
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Person.java
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/util/
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManager.java
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManagerServlet.java
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionFactoryInitializer.java
trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionInterceptor.java
trunk/Hibernate3/documentation/tutorial/src/main/resources/org/
trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/
trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/
trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/
trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Event.hbm.xml
trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml
Removed:
trunk/Hibernate3/documentation/tutorial/src/main/java/events/
trunk/Hibernate3/documentation/tutorial/src/main/java/util/
Modified:
trunk/Hibernate3/documentation/tutorial/pom.xml
trunk/Hibernate3/documentation/tutorial/src/main/resources/hibernate.cfg.xml
trunk/Hibernate3/documentation/tutorial/src/main/resources/log4j.properties
trunk/Hibernate3/documentation/tutorial/src/main/webapp/WEB-INF/web.xml
Log:
completed migration of tutorial
Modified: trunk/Hibernate3/documentation/tutorial/pom.xml
===================================================================
--- trunk/Hibernate3/documentation/tutorial/pom.xml 2007-05-26 03:48:22 UTC (rev 11569)
+++ trunk/Hibernate3/documentation/tutorial/pom.xml 2007-05-26 04:50:07 UTC (rev 11570)
@@ -1,27 +1,32 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core-project</artifactId>
- <version>3.3.0.beta1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-tutorial</artifactId>
- <packaging>jar</packaging>
- <name>Hibernate Tutorial</name>
- <description>A tutorial project showcasing Hibernate usage</description>
-
- <dependencies>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- </dependency>
- </dependencies>
-
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core-project</artifactId>
+ <version>3.3.0.beta1</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-tutorial</artifactId>
+ <packaging>war</packaging>
+ <name>Hibernate Tutorial</name>
+ <description>A tutorial project showcasing Hibernate usage</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
+
</project>
Copied: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Event.java (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/events/Event.java)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Event.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Event.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,48 @@
+package org.hibernate.tutorial.domain;
+
+import java.util.*;
+
+public class Event {
+ private Long id;
+
+ private String title;
+ private Date date;
+
+ public Event() {}
+
+ public Long getId() {
+ return id;
+ }
+
+ private void setId(Long id) {
+ this.id = id;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+
+ private Set participants = new HashSet();
+
+ public Set getParticipants() {
+ return participants;
+ }
+
+ public void setParticipants(Set participants) {
+ this.participants = participants;
+ }
+
+}
\ No newline at end of file
Copied: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Person.java (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/events/Person.java)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Person.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/domain/Person.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,80 @@
+package org.hibernate.tutorial.domain;
+
+import java.util.*;
+
+public class Person {
+
+ private Long id;
+ private int age;
+ private String firstname;
+ private String lastname;
+
+ public Person() {}
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+
+ private Set emailAddresses = new HashSet();
+
+ public Set getEmailAddresses() {
+ return emailAddresses;
+ }
+
+ public void setEmailAddresses(Set emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+
+
+ private Set events = new HashSet();
+
+ // Defensive, convenience methods
+ protected Set getEvents() {
+ return events;
+ }
+
+ protected void setEvents(Set events) {
+ this.events = events;
+ }
+
+ public void addToEvent(Event event) {
+ this.getEvents().add(event);
+ event.getParticipants().add(this);
+ }
+
+ public void removeFromEvent(Event event) {
+ this.getEvents().remove(event);
+ event.getParticipants().remove(this);
+ }
+
+}
\ No newline at end of file
Copied: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/util/HibernateUtil.java)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/util/HibernateUtil.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,25 @@
+package org.hibernate.tutorial.util;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+
+public class HibernateUtil {
+
+ private static final SessionFactory sessionFactory;
+
+ static {
+ try {
+ // Create the SessionFactory from hibernate.cfg.xml
+ sessionFactory = new Configuration().configure().buildSessionFactory();
+ } catch (Throwable ex) {
+ // Make sure you log the exception, as it might be swallowed
+ System.err.println("Initial SessionFactory creation failed." + ex);
+ throw new ExceptionInInitializerError(ex);
+ }
+ }
+
+ public static SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+
+}
\ No newline at end of file
Copied: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManager.java (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/events/EventManager.java)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManager.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManager.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,138 @@
+package org.hibernate.tutorial.web;
+
+import java.util.Date;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.tutorial.domain.Event;
+import org.hibernate.tutorial.domain.Person;
+import org.hibernate.tutorial.util.HibernateUtil;
+
+public class EventManager {
+
+ public static void main(String[] args) {
+ EventManager mgr = new EventManager();
+
+ if (args[0].equals("store")) {
+ mgr.createAndStoreEvent("My Event", new Date());
+ }
+ else if (args[0].equals("list")) {
+ List events = mgr.listEvents();
+ for (int i = 0; i < events.size(); i++) {
+ Event theEvent = (Event) events.get(i);
+ System.out.println("Event: " + theEvent.getTitle() +
+ " Time: " + theEvent.getDate());
+ }
+ }
+ else if (args[0].equals("addpersontoevent")) {
+ Long eventId = mgr.createAndStoreEvent("My Event", new Date());
+ Long personId = mgr.createAndStorePerson("Foo", "Bar");
+ mgr.addPersonToEvent(personId, eventId);
+ System.out.println("Added person " + personId + " to event " + eventId);
+ }
+ else if (args[0].equals("addemailtoperson")) {
+ Long personId = mgr.createAndStorePerson("Foozy", "Beary");
+ mgr.addEmailToPerson(personId, "foo@bar");
+ mgr.addEmailToPerson(personId, "bar@foo");
+ System.out.println("Added two email addresses (value typed objects) to person entity : " + personId);
+ }
+
+ HibernateUtil.getSessionFactory().close();
+ }
+
+ private Long createAndStoreEvent(String title, Date theDate) {
+
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ session.beginTransaction();
+
+ Event theEvent = new Event();
+ theEvent.setTitle(title);
+ theEvent.setDate(theDate);
+
+ session.save(theEvent);
+
+ session.getTransaction().commit();
+
+ return theEvent.getId();
+ }
+
+ private Long createAndStorePerson(String firstname, String lastname) {
+
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ session.beginTransaction();
+
+ Person thePerson = new Person();
+ thePerson.setFirstname(firstname);
+ thePerson.setLastname(lastname);
+
+ session.save(thePerson);
+
+ session.getTransaction().commit();
+
+ return thePerson.getId();
+ }
+
+
+ private List listEvents() {
+
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ session.beginTransaction();
+
+ List result = session.createQuery("from Event").list();
+
+ session.getTransaction().commit();
+
+ return result;
+ }
+
+ private void addPersonToEvent(Long personId, Long eventId) {
+
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ session.beginTransaction();
+
+ Person aPerson = (Person) session
+ .createQuery("select p from Person p left join fetch p.events where p.id = :pid")
+ .setParameter("pid", personId)
+ .uniqueResult(); // Eager fetch the collection so we can use it detached
+
+ Event anEvent = (Event) session.load(Event.class, eventId);
+ // If we want to handle it bidirectional and detached, we also need to load this
+ // collection with an eager outer-join fetch, this time with Criteria and not HQL:
+ /*
+ Event anEvent = (Event) session
+ .createCriteria(Event.class).setFetchMode("participants", FetchMode.JOIN)
+ .add( Expression.eq("id", eventId) )
+ .uniqueResult(); // Eager fetch the colleciton so we can use it detached
+ */
+
+ session.getTransaction().commit();
+
+ // End of first unit of work
+
+ aPerson.addToEvent( anEvent );
+ // or bidirectional safety method, setting both sides: aPerson.addToEvent(anEvent);
+
+ // Begin second unit of work
+
+ Session session2 = HibernateUtil.getSessionFactory().getCurrentSession();
+ session2.beginTransaction();
+
+ session2.update(aPerson); // Reattachment of aPerson
+
+ session2.getTransaction().commit();
+ }
+
+ private void addEmailToPerson(Long personId, String emailAddress) {
+
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ session.beginTransaction();
+
+ Person aPerson = ( Person ) session.load(Person.class, personId);
+
+ // The getEmailAddresses() might trigger a lazy load of the collection
+ aPerson.getEmailAddresses().add(emailAddress);
+
+ session.getTransaction().commit();
+ }
+
+}
\ No newline at end of file
Copied: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManagerServlet.java (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/events/EventManagerServlet.java)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManagerServlet.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/EventManagerServlet.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,106 @@
+package org.hibernate.tutorial.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hibernate.tutorial.domain.Event;
+import org.hibernate.tutorial.util.HibernateUtil;
+
+public class EventManagerServlet extends HttpServlet {
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy");
+
+ try {
+ // Begin unit of work
+ HibernateUtil.getSessionFactory()
+ .getCurrentSession().beginTransaction();
+
+ // Write HTML header
+ PrintWriter out = response.getWriter();
+ out.println("<html><head><title>Event Manager</title></head><body>");
+
+ // Handle actions
+ if ( "store".equals(request.getParameter("action")) ) {
+
+ String eventTitle = request.getParameter("eventTitle");
+ String eventDate = request.getParameter("eventDate");
+
+ if ( "".equals(eventTitle) || "".equals(eventDate) ) {
+ out.println("<b><i>Please enter event title and date.</i></b>");
+ } else {
+ createAndStoreEvent(eventTitle, dateFormatter.parse(eventDate));
+ out.println("<b><i>Added event.</i></b>");
+ }
+ }
+
+ // Print page
+ printEventForm(out);
+ listEvents(out, dateFormatter);
+
+ // Write HTML footer
+ out.println("</body></html>");
+ out.flush();
+ out.close();
+
+ // End unit of work
+ HibernateUtil.getSessionFactory()
+ .getCurrentSession().getTransaction().commit();
+
+ } catch (Exception ex) {
+ HibernateUtil.getSessionFactory()
+ .getCurrentSession().getTransaction().rollback();
+ throw new ServletException(ex);
+ }
+ }
+
+ private void printEventForm(PrintWriter out) {
+ out.println("<h2>Add new event:</h2>");
+ out.println("<form>");
+ out.println("Title: <input name='eventTitle' length='50'/><br/>");
+ out.println("Date (e.g. 24.12.2009): <input name='eventDate' length='10'/><br/>");
+ out.println("<input type='submit' name='action' value='store'/>");
+ out.println("</form>");
+ }
+
+ private void listEvents(PrintWriter out, SimpleDateFormat dateFormatter) {
+ List result = HibernateUtil.getSessionFactory()
+ .getCurrentSession().createCriteria(Event.class).list();
+ if (result.size() > 0) {
+ out.println("<h2>Events in database:</h2>");
+ out.println("<table border='1'>");
+ out.println("<tr>");
+ out.println("<th>Event title</th>");
+ out.println("<th>Event date</th>");
+ out.println("</tr>");
+ for (Iterator it = result.iterator(); it.hasNext();) {
+ Event event = (Event) it.next();
+ out.println("<tr>");
+ out.println("<td>" + event.getTitle() + "</td>");
+ out.println("<td>" + dateFormatter.format(event.getDate()) + "</td>");
+ out.println("</tr>");
+ }
+ out.println("</table>");
+ }
+ }
+
+ protected void createAndStoreEvent(String title, Date theDate) {
+ Event theEvent = new Event();
+ theEvent.setTitle(title);
+ theEvent.setDate(theDate);
+
+ HibernateUtil.getSessionFactory()
+ .getCurrentSession().save(theEvent);
+ }
+
+}
Added: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionFactoryInitializer.java
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionFactoryInitializer.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionFactoryInitializer.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,24 @@
+package org.hibernate.tutorial.web;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.hibernate.tutorial.util.HibernateUtil;
+
+/**
+ * Demonstrates good practice of making sure the SessionFactory is initialized
+ * on application startup, rather than on first request. Here we register
+ * as a listener to the servlet context lifecycle for building/closing of the
+ * SessionFactory.
+ *
+ * @author Steve Ebersole
+ */
+public class SessionFactoryInitializer implements ServletContextListener {
+ public void contextInitialized(ServletContextEvent event) {
+ HibernateUtil.getSessionFactory();
+ }
+
+ public void contextDestroyed(ServletContextEvent event) {
+ HibernateUtil.getSessionFactory().close();
+ }
+}
Added: trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionInterceptor.java
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionInterceptor.java (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/java/org/hibernate/tutorial/web/SessionInterceptor.java 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,62 @@
+package org.hibernate.tutorial.web;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.hibernate.classic.Session;
+import org.hibernate.context.ManagedSessionContext;
+import org.hibernate.tutorial.util.HibernateUtil;
+
+/**
+ * Illustrates a servlet filter used to apply a Hibernate session
+ * to the "context" of the web request.
+ *
+ * @author Steve Ebersole
+ */
+public class SessionInterceptor implements Filter {
+
+ private static final Log log = LogFactory.getLog( SessionInterceptor.class );
+
+ public void doFilter(
+ ServletRequest request,
+ ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ log.trace( "===> opening session for request [" + request.hashCode() + "]" );
+ // Start the session to be used for this request
+ Session session = HibernateUtil.getSessionFactory().openSession();
+
+ try {
+ // make the session available to the session factory's "current context"
+ ManagedSessionContext.bind( session );
+
+ // pass control along to the rest of the processing chain
+ chain.doFilter( request, response );
+ }
+ finally {
+ log.trace( "===> cleaning-up session for request [" + request.hashCode() + "]" );
+ // remove session from "current context"
+ ManagedSessionContext.unbind( HibernateUtil.getSessionFactory() );
+
+ try {
+ session.close();
+ }
+ catch( Throwable t ) {
+ log.warn( "was unable to properly close session for request [" + request.hashCode() + "]" );
+ }
+ }
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+}
Modified: trunk/Hibernate3/documentation/tutorial/src/main/resources/hibernate.cfg.xml
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/resources/hibernate.cfg.xml 2007-05-26 03:48:22 UTC (rev 11569)
+++ trunk/Hibernate3/documentation/tutorial/src/main/resources/hibernate.cfg.xml 2007-05-26 04:50:07 UTC (rev 11570)
@@ -14,13 +14,13 @@
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
- <property name="connection.pool_size">1</property>
+ <property name="connection.pool_size">2</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
- <!-- Enable Hibernate's automatic session context management -->
- <property name="current_session_context_class">thread</property>
+ <!-- Enable Hibernate's current session context -->
+ <property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
@@ -31,8 +31,8 @@
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
- <mapping resource="events/Event.hbm.xml"/>
- <mapping resource="events/Person.hbm.xml"/>
+ <mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml"/>
+ <mapping resource="org/hibernate/tutorial/domain/Person.hbm.xml"/>
</session-factory>
Modified: trunk/Hibernate3/documentation/tutorial/src/main/resources/log4j.properties
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/resources/log4j.properties 2007-05-26 03:48:22 UTC (rev 11569)
+++ trunk/Hibernate3/documentation/tutorial/src/main/resources/log4j.properties 2007-05-26 04:50:07 UTC (rev 11570)
@@ -4,12 +4,6 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
-### direct messages to file hibernate.log ###
-#log4j.appender.file=org.apache.log4j.FileAppender
-#log4j.appender.file.File=hibernate.log
-#log4j.appender.file.layout=org.apache.log4j.PatternLayout
-#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
-
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
Copied: trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Event.hbm.xml (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/events/Event.hbm.xml)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Event.hbm.xml (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Event.hbm.xml 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,23 @@
+<?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.tutorial.domain">
+
+ <class name="Event" table="EVENTS">
+ <id name="id" column="EVENT_ID">
+ <generator class="native"/>
+ </id>
+ <property name="date" type="timestamp" column="EVENT_DATE"/>
+ <property name="title"/>
+
+ <set name="participants" table="PERSON_EVENT" inverse="true">
+ <key column="EVENT_ID"/>
+ <many-to-many column="PERSON_ID" class="Person"/>
+ </set>
+
+ </class>
+
+
+</hibernate-mapping>
\ No newline at end of file
Copied: trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml (from rev 11563, trunk/Hibernate3/documentation/tutorial/src/main/java/events/Person.hbm.xml)
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml (rev 0)
+++ trunk/Hibernate3/documentation/tutorial/src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml 2007-05-26 04:50:07 UTC (rev 11570)
@@ -0,0 +1,28 @@
+<?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.tutorial.domain">
+
+ <class name="Person" table="PERSON">
+ <id name="id" column="PERSON_ID">
+ <generator class="native"/>
+ </id>
+ <property name="age"/>
+ <property name="firstname"/>
+ <property name="lastname"/>
+
+ <set name="events" table="PERSON_EVENT">
+ <key column="PERSON_ID"/>
+ <many-to-many column="EVENT_ID" class="Event"/>
+ </set>
+
+ <set name="emailAddresses" table="PERSON_EMAIL_ADDR">
+ <key column="PERSON_ID"/>
+ <element type="string" column="EMAIL_ADDR"/>
+ </set>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/Hibernate3/documentation/tutorial/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/Hibernate3/documentation/tutorial/src/main/webapp/WEB-INF/web.xml 2007-05-26 03:48:22 UTC (rev 11569)
+++ trunk/Hibernate3/documentation/tutorial/src/main/webapp/WEB-INF/web.xml 2007-05-26 04:50:07 UTC (rev 11570)
@@ -4,13 +4,28 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <listener>
+ <listener-class>org.hibernate.tutorial.web.SessionFactoryInitializer</listener-class>
+ </listener>
+
<servlet>
<servlet-name>Event Manager</servlet-name>
- <servlet-class>events.EventManagerServlet</servlet-class>
+ <servlet-class>org.hibernate.tutorial.web.EventManagerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Event Manager</servlet-name>
<url-pattern>/eventmanager</url-pattern>
</servlet-mapping>
+
+ <filter>
+ <filter-name>Session Interceptor</filter-name>
+ <filter-class>org.hibernate.tutorial.web.SessionInterceptor</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Session Interceptor</filter-name>
+ <servlet-name>Event Manager</servlet-name>
+ </filter-mapping>
+
</web-app>
17 years, 6 months
Hibernate SVN: r11569 - trunk/Hibernate3/documentation/manual.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-25 23:48:22 -0400 (Fri, 25 May 2007)
New Revision: 11569
Modified:
trunk/Hibernate3/documentation/manual/pom.xml
Log:
grrr
Modified: trunk/Hibernate3/documentation/manual/pom.xml
===================================================================
--- trunk/Hibernate3/documentation/manual/pom.xml 2007-05-26 01:35:53 UTC (rev 11568)
+++ trunk/Hibernate3/documentation/manual/pom.xml 2007-05-26 03:48:22 UTC (rev 11569)
@@ -16,19 +16,6 @@
<name>Hibernate Manual</name>
<description>The Hibernate reference manual</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-jboss-docbook-plugin</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-docbook-xslt</artifactId>
- <version>0.1</version>
- </dependency>
- </dependencies>
-
<modules>
<module>en-US</module>
<module>fr-FR</module>
@@ -39,6 +26,7 @@
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jboss-docbook-plugin</artifactId>
+ <version>1.0</version>
<executions>
<execution>
<goals>
17 years, 6 months
Hibernate SVN: r11568 - trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-25 21:35:53 -0400 (Fri, 25 May 2007)
New Revision: 11568
Modified:
trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java
trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java
Log:
missed changes in initial migration
Modified: trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java
===================================================================
--- trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java 2007-05-26 01:35:31 UTC (rev 11567)
+++ trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/OptimisticTreeCache.java 2007-05-26 01:35:53 UTC (rev 11568)
@@ -23,7 +23,7 @@
*
* @author Steve Ebersole
*/
-public class OptimisticTreeCache implements OptimisticCache {
+public class OptimisticTreeCache implements OptimisticCache, TransactionAwareCache {
// todo : eventually merge this with TreeCache and just add optional opt-lock support there.
Modified: trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java
===================================================================
--- trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java 2007-05-26 01:35:31 UTC (rev 11567)
+++ trunk/Hibernate3/cache-jbosscache/src/main/java/org/hibernate/cache/TreeCache.java 2007-05-26 01:35:53 UTC (rev 11568)
@@ -20,7 +20,7 @@
*
* @author Gavin King
*/
-public class TreeCache implements Cache {
+public class TreeCache implements Cache, TransactionAwareCache {
private static final Log log = LogFactory.getLog(TreeCache.class);
17 years, 6 months
Hibernate SVN: r11567 - in trunk/Hibernate3/core/src/main/java/org/hibernate: cache/impl/bridge and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-25 21:35:31 -0400 (Fri, 25 May 2007)
New Revision: 11567
Added:
trunk/Hibernate3/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java
Modified:
trunk/Hibernate3/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java
trunk/Hibernate3/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
Log:
missed changes in initial migration
Added: trunk/Hibernate3/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java
===================================================================
--- trunk/Hibernate3/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java (rev 0)
+++ trunk/Hibernate3/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java 2007-05-26 01:35:31 UTC (rev 11567)
@@ -0,0 +1,11 @@
+package org.hibernate.cache;
+
+/**
+ * Marker interface for identifying cache impls which are aware of
+ * JTA transactions
+ *
+ * @author Steve Ebersole
+ */
+public interface TransactionAwareCache {
+}
+
Modified: trunk/Hibernate3/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java
===================================================================
--- trunk/Hibernate3/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java 2007-05-25 22:35:59 UTC (rev 11566)
+++ trunk/Hibernate3/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java 2007-05-26 01:35:31 UTC (rev 11567)
@@ -10,7 +10,9 @@
*
* @author Steve Ebersole
*/
-public abstract class BaseTransactionalDataRegionAdapter extends BaseRegionAdapter implements TransactionalDataRegion {
+public abstract class BaseTransactionalDataRegionAdapter
+ extends BaseRegionAdapter
+ implements TransactionalDataRegion {
protected final CacheDataDescription metadata;
@@ -20,44 +22,10 @@
}
public boolean isTransactionAware() {
- return underlyingCache instanceof org.hibernate.cache.TreeCache
- || underlyingCache instanceof org.hibernate.cache.OptimisticTreeCache;
+ return underlyingCache instanceof org.hibernate.cache.TransactionAwareCache;
}
public CacheDataDescription getCacheDataDescription() {
return metadata;
}
-
-// public void lock() throws CacheException {
-// // impl note: unfortunately this was not a capability of the original Cache contract
-// }
-//
-// public void unlock() throws CacheException {
-// // impl note: unfortunately this was not a capability of the original Cache contract
-// }
-//
-// public void lock(Object key) throws CacheException {
-// underlyingCache.lock( key );
-// }
-//
-// public void unlock(Object key) throws CacheException {
-// underlyingCache.unlock( key );
-// }
-//
-// public Object get(Object key) throws CacheException {
-// return underlyingCache.get( key );
-// }
-//
-// public Object read(Object key) throws CacheException {
-// return underlyingCache.read( key );
-// }
-//
-// public void writeLoad(Object key, Object value, Object version) throws CacheException {
-// if ( underlyingCache instanceof OptimisticCache ) {
-// ( ( OptimisticCache ) underlyingCache ).writeLoad( key, value, version );
-// }
-// else {
-// underlyingCache.put( key, value );
-// }
-// }
}
Modified: trunk/Hibernate3/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
===================================================================
--- trunk/Hibernate3/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2007-05-25 22:35:59 UTC (rev 11566)
+++ trunk/Hibernate3/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2007-05-26 01:35:31 UTC (rev 11567)
@@ -80,16 +80,6 @@
else if ( properties.getProperty(Environment.DATASOURCE)!=null ) {
connections = new DatasourceConnectionProvider();
}
- else if ( properties.getProperty(Environment.C3P0_MAX_SIZE)!=null ) {
- connections = new C3P0ConnectionProvider();
- }
- else if (
- properties.getProperty(Environment.PROXOOL_XML)!=null ||
- properties.getProperty(Environment.PROXOOL_PROPERTIES)!=null ||
- properties.getProperty(Environment.PROXOOL_EXISTING_POOL)!=null
- ) {
- connections = new ProxoolConnectionProvider();
- }
else if ( properties.getProperty(Environment.URL)!=null ) {
connections = new DriverManagerConnectionProvider();
}
17 years, 6 months
Hibernate SVN: r11566 - trunk/Hibernate3/documentation/manual.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-05-25 18:35:59 -0400 (Fri, 25 May 2007)
New Revision: 11566
Modified:
trunk/Hibernate3/documentation/manual/pom.xml
Log:
fixed broken title image link
Modified: trunk/Hibernate3/documentation/manual/pom.xml
===================================================================
--- trunk/Hibernate3/documentation/manual/pom.xml 2007-05-25 21:07:35 UTC (rev 11565)
+++ trunk/Hibernate3/documentation/manual/pom.xml 2007-05-25 22:35:59 UTC (rev 11566)
@@ -74,7 +74,7 @@
<transformerParameters>
<property>
<name>custom.titlepage.img</name>
- <value>${basedir}/src/main/docbook/standard/resources/shared/images/hibernate_logo_a.png</value>
+ <value>${basedir}/src/main/resources/shared/images/hibernate_logo_a.png</value>
</property>
</transformerParameters>
</options>
17 years, 6 months