[hibernate-commits] Hibernate SVN: r14169 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/cfg/reveng/dialect and 6 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Nov 1 06:29:38 EDT 2007


Author: max.andersen at jboss.com
Date: 2007-11-01 06:29:37 -0400 (Thu, 01 Nov 2007)
New Revision: 14169

Modified:
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableIdentifier.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/column.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
   branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java
Log:
removed empty <comment> elements
fixed cachedmetadatadialect
exposed more setters on exporters

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCReader.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -413,7 +413,8 @@
 	      	}	      	
 	      }
 
-	      Iterator suggestedPrimaryKeyStrategyName = getMetaDataDialect().getSuggestedPrimaryKeyStrategyName( getCatalogForDBLookup(table.getCatalog()), getSchemaForDBLookup(table.getSchema()), table.getName() );	      
+	      Iterator suggestedPrimaryKeyStrategyName = getMetaDataDialect().getSuggestedPrimaryKeyStrategyName( getCatalogForDBLookup(table.getCatalog()), getSchemaForDBLookup(table.getSchema()), table.getName() );
+	      try {
 	      if(suggestedPrimaryKeyStrategyName.hasNext()) {
 	    	  Map m = (Map) suggestedPrimaryKeyStrategyName.next();
 	    	  String suggestion = (String) m.get( "HIBERNATE_STRATEGY" );
@@ -421,6 +422,15 @@
 	    		  dbs.addSuggestedIdentifierStrategy( table.getCatalog(), table.getSchema(), table.getName(), suggestion );
 	    	  }
 	      }
+	      } finally {
+	    	  if(suggestedPrimaryKeyStrategyName!=null) {
+					try {
+						getMetaDataDialect().close(suggestedPrimaryKeyStrategyName);
+					} catch(JDBCException se) {
+						log.warn("Exception while closing iterator for suggested primary key strategy name",se);
+					}
+				}	    	  
+	      }
 	      	      
 	      if(key!=null) {
 	    	  cols = columns.iterator();

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableIdentifier.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableIdentifier.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/TableIdentifier.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -71,7 +71,7 @@
 	
 	public String toString() {
 		StringBuffer buf = new StringBuffer()
-					.append( getClass().getName() )
+					.append( "TableIdentifier" )
 					.append('(');
 		if ( getCatalog()!=null ) buf.append( getCatalog() + "." );
 		if ( getSchema()!=null ) buf.append( getSchema()+ ".");

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/CachedMetaDataDialect.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -17,6 +17,7 @@
 	private Map cachedExportedKeys = new HashMap();
 	private Map cachedPrimaryKeys = new HashMap();
 	private Map cachedIndexInfo = new HashMap();
+	private Map cachedPrimaryKeyStrategyName = new HashMap();
 
 	public CachedMetaDataDialect(MetaDataDialect realMetaData) {
 		this.delegate = realMetaData;
@@ -96,6 +97,17 @@
 		}
 	}
 
+	public Iterator getSuggestedPrimaryKeyStrategyName(String catalog, String schema, String table) {
+		StringKey sk = new StringKey(new String[] { catalog, schema, table });
+		List cached = (List) cachedPrimaryKeyStrategyName.get( sk );
+		if(cached==null) {
+			cached = new ArrayList();
+			return new CachedIterator(this, cachedPrimaryKeyStrategyName, sk, cached, delegate.getSuggestedPrimaryKeyStrategyName( catalog, schema, table ));
+		} else {
+			return cached.iterator();
+		}
+	}
+	
 	public boolean needQuote(String name) {
 		return delegate.needQuote( name );
 	}
@@ -181,6 +193,7 @@
 
 		public void store() {
 			destination.put( target, cache );
+			if(realIterator.hasNext()) throw new IllegalStateException("CachedMetaDataDialect have not been fully initialized!");
 			cache = null;
 			target = null;
 			destination = null;
@@ -188,8 +201,5 @@
 		}
 	}
 
-	public Iterator getSuggestedPrimaryKeyStrategyName(String catalog, String schema, String name) {
-		return delegate.getSuggestedPrimaryKeyStrategyName( catalog, schema, name );
-	}
 		
 }

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/AbstractExporter.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -108,6 +108,10 @@
 		this.templatePaths = templatePaths;
 	}
 
+	public String[] getTemplatePath() {
+		return templatePaths;
+	}
+	
 	static String toString(Object[] a) {
         if (a == null)
             return "null";

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Exporter.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -19,27 +19,29 @@
 	 */
 	public void setConfiguration(Configuration cfg);
 
+	public Configuration getConfiguration();
+	
 	/**
 	 * @param file basedirectory to be used for generated files.
 	 */
 	public void setOutputDirectory(File file);
 
+	public File getOutputDirectory();
+	
 	/**
 	 * @param templatePath array of directories used sequentially to lookup templates
 	 */
 	public void setTemplatePath(String[] templatePath);
 	
+	public String[] getTemplatePath();
+	
 	/**
-	 * @param templatePrefix template prefix to be used. e.g. if set to "dao/", "dao/" will be prefixed all lookups before the simple name will looked up. Used to allow seperation of templates within a templatepath.  
-	 */
-//	public void setTemplatePrefix(String templatePrefix);
-
-	/**
 	 * 
 	 * @param properties set of properties to be used by exporter.
 	 */
 	public void setProperties(Properties properties);
 	
+	public Properties getProperties();
 	
 	/**
 	 * 

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/column.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/column.hbm.ftl	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/column.hbm.ftl	2007-11-01 10:29:37 UTC (rev 14169)
@@ -1,7 +1,7 @@
 <#if column.isFormula()>
 <formula>${column.getFormula()}</formula>
 <#else>
-<column name="${column.quotedName}" ${c2h.columnAttributes(column)}<#if column.comment?exists>>
+<column name="${column.quotedName}" ${c2h.columnAttributes(column)}<#if column.comment?exists && column.comment?trim?length!=0>>
 <comment>${column.comment}</comment>
 </column><#else>/>
 </#if>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl	2007-11-01 10:29:37 UTC (rev 14169)
@@ -62,7 +62,7 @@
 <#assign metaattributable=clazz/>
 <#include "meta.hbm.ftl"/>
 
-<#if clazz.table.comment?exists>
+<#if clazz.table.comment?exists  && clazz.table.comment?trim?length!=0>
  <comment>${clazz.table.comment}</comment>
 </#if>
 <#-- TODO: move this to id.hbm.ftl -->

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/CachedMetaDataTest.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -109,7 +109,7 @@
 			if(failOnDelegateAccess) {
 				throw new IllegalStateException("delegate not accessible");
 			} else {
-				return delegate.getTables( catalog, schema, name );
+				return delegate.getSuggestedPrimaryKeyStrategyName(catalog, schema, name);
 			}
 		}
 		

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2JavaEjb3Test.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -43,6 +43,10 @@
 		exporter.start();
 	}
 
+	protected void tearDown() throws Exception {
+		// TODO Auto-generated method stub
+		super.tearDown();
+	}
 	
 
 	public void testFileExistence() {

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml	2007-11-01 10:29:37 UTC (rev 14169)
@@ -59,6 +59,14 @@
     		</column>
     	</property>
 
+        <property name="columnDetails" 
+    		type="string" 
+    	>
+    		<column name="columnd" length="200" not-null="true" sql-type="varchar(200)" unique="true" >
+    		  <comment></comment><!--  empty comment -->
+    		</column>
+    	</property>
+
     	<property name="vitualValue" 
     		not-null="true" 
     		length="200"

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -10,6 +10,8 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -198,8 +200,8 @@
 		return db;
 	}
 
-	public static String buildClasspath(List jars) {
-		StringBuffer classpath = new StringBuffer();
+	private static List buildClasspathFiles(List jars) {
+		List classpath = new ArrayList();
 		String dir = System.getProperty("org.hibernate.tool.test.libdir", "lib" + File.separator + "testlibs");
 		if(dir==null) {
 			throw new IllegalStateException("System property org.hibernate.tool.test.libdir must be set to run tests that compile with a custom classpath");
@@ -214,6 +216,19 @@
 			if(!f.exists()) {
 				throw new IllegalStateException(f + " not found. Check if system property org.hibernate.tool.test.libdir is set correctly.");
 			}
+			classpath.add(f);			
+		}
+		
+		return classpath;
+	}
+
+	public static String buildClasspath(List jars) {
+		List files = buildClasspathFiles(jars);
+		StringBuffer classpath = new StringBuffer();
+		
+		Iterator iterator = files.iterator();
+		while (iterator.hasNext()) {
+			File f = (File) iterator.next();
 			classpath.append(f);
 			if(iterator.hasNext()) {
 				classpath.append(File.pathSeparatorChar);
@@ -222,7 +237,23 @@
 		
 		return classpath.toString();
 	}
-
+	
+	public static URL[] buildClasspathURLS(List jars, File outputDir) throws MalformedURLException {
+		List files = buildClasspathFiles(jars);
+		List classpath = new ArrayList();
+		
+		if(outputDir!=null) {
+			classpath.add(outputDir.toURL());
+		}
+		Iterator iterator = files.iterator();
+		while (iterator.hasNext()) {
+			File f = (File) iterator.next();
+			classpath.add(f.toURL());			
+		}
+		
+		return (URL[]) classpath.toArray(new URL[classpath.size()]);
+	}
+	
 	static public String findFirstString(String string, File file) {
 		try {
 	        BufferedReader in = new BufferedReader(new FileReader(file) );

Modified: branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java	2007-11-01 10:28:11 UTC (rev 14168)
+++ branches/Branch_3_2/HibernateExt/tools/src/test5.0/org/hibernate/tool/hbm2x/Hbm2JavaEjb3ForJDK50Test.java	2007-11-01 10:29:37 UTC (rev 14169)
@@ -2,6 +2,8 @@
 
 import java.io.File;
 import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
@@ -9,10 +11,12 @@
 import java.util.List;
 import java.util.Set;
 
+import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
 import org.hibernate.cfg.AnnotationConfiguration;
 import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
 import org.hibernate.tool.test.TestHelper;
 
 /**
@@ -52,8 +56,7 @@
 
 		ArrayList list = new ArrayList();
 		List jars = new ArrayList();
-		jars.add( "ejb3-persistence.jar" );
-		jars.add( "hibernate-annotations.jar" );
+		addAnnotationJars(jars);
 		TestHelper.compile(
 				getOutputDir(), file, TestHelper.visitAllFiles( getOutputDir(), list ), "1.5",
 				TestHelper.buildClasspath( jars )
@@ -69,8 +72,7 @@
 
 		ArrayList list = new ArrayList();
 		List jars = new ArrayList();
-		jars.add( "ejb3-persistence.jar" );
-		jars.add( "hibernate-annotations.jar" );
+		addAnnotationJars(jars);
 		TestHelper.compile(
 				getOutputDir(), file, TestHelper.visitAllFiles( getOutputDir(), list ), "1.5",
 				TestHelper.buildClasspath( jars )
@@ -173,63 +175,156 @@
 	public void testTableGenerator() throws Exception {
 		testGenerator( "Bungalow" );
 	}
-
-	private void testGenerator(String className) throws Exception {
+	
+	public void testCreateAnnotationConfiguration() throws Exception {
+		
 		File file = new File( "ejb3compilable" );
 		file.mkdir();
 
 		ArrayList list = new ArrayList();
 		List jars = new ArrayList();
-		jars.add( "ejb3-persistence.jar" );
-		jars.add( "hibernate-annotations.jar" );
-		TestHelper.compile(
-				getOutputDir(), file, TestHelper.visitAllFiles( getOutputDir(), list ), "1.5",
-				TestHelper.buildClasspath( jars )
-		);
-		URL[] urls = new URL[]{file.toURL()};
-		Thread currentThread = Thread.currentThread();
-		URLClassLoader ucl = new URLClassLoader( urls, currentThread.getContextClassLoader() );
-		currentThread.setContextClassLoader( ucl );
+		addAnnotationJars(jars);
+		
+		new ExecuteContext(getOutputDir(), file, jars) {
 
-		AnnotationConfiguration configuration = new AnnotationConfiguration();
-		Class puppet = ucl.loadClass( "org.hibernate.tool.hbm2x." + className );
-		configuration.addAnnotatedClass( puppet );
+			protected void execute() throws Exception {
+				AnnotationConfiguration configuration = new AnnotationConfiguration();
+				configuration.addAnnotatedClass( getUcl().loadClass( "org.hibernate.tool.hbm2x.Train" ) );
+				configuration.addAnnotatedClass( getUcl().loadClass( "org.hibernate.tool.hbm2x.Passenger" ) );
 
-		configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
-		SessionFactory sf = configuration.buildSessionFactory();
-		Session s = sf.openSession();
+				configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
+				SessionFactory sf = configuration.buildSessionFactory();
+				Session s = sf.openSession();
+                Query createQuery = s.createQuery("from java.lang.Object");
+                createQuery.list();
+				s.close();
+				sf.close();
+				
+			}
+			
+		}.run();
+	}
 
-		Object puppetInst = puppet.newInstance();
-		puppet.getMethod( "setName", new Class[]{String.class} ).invoke( puppetInst, new Object[]{"Barbie"} );
+	static abstract class ExecuteContext {
+	
+		private final File sourceDir;
+		private final File outputDir;
+		private final List jars;
+		private URLClassLoader ucl;
+
+		public ExecuteContext(File sourceDir, File outputDir, List jars) {
+			this.sourceDir = sourceDir;
+			this.outputDir = outputDir;
+			this.jars = jars;
+		}
 		
-		if(className.equals("Bungalow")) { // hack to avoid not-null execption
-			puppet.getMethod("setMascot", new Class[] { puppet }).invoke( puppetInst, new Object[] { puppetInst } );
+		public void run() throws Exception {
+			
+			TestHelper.compile(
+					sourceDir, outputDir, TestHelper.visitAllFiles( sourceDir, new ArrayList() ), "1.5",
+					TestHelper.buildClasspath( jars )
+			);
+			URL[] urls = TestHelper.buildClasspathURLS(jars, outputDir);
+			
+			Thread currentThread = null;
+			ClassLoader contextClassLoader = null;
+			
+			try {
+			currentThread = Thread.currentThread();
+			contextClassLoader = currentThread.getContextClassLoader();
+			ucl = new URLClassLoader( urls, contextClassLoader ) {
+				
+				public Class loadClass(String name)
+						throws ClassNotFoundException {
+					// TODO Auto-generated method stub
+					return super.loadClass(name);
+				}
+				
+				
+			};
+			currentThread.setContextClassLoader( ucl );
+
+			execute();
+			
+			} finally {
+				currentThread.setContextClassLoader( contextClassLoader );
+				TestHelper.deleteDir( outputDir );
+			}
 		}
+
+		public URLClassLoader getUcl() {
+			return ucl;
+		}
 		
-		s.getTransaction().begin();
-		s.persist( puppetInst );
-		s.getTransaction().commit();
-		s.clear();
+		abstract protected void execute() throws Exception;
+		
+	}
+	
+	private void testGenerator(final String className) throws Exception {
+		
+		File file = new File( "ejb3compilable" );
+		file.mkdir();
 
-		s.getTransaction().begin();
-		Object puppetInst2 = s.get(
-				puppet,
-				(Serializable) puppet.getMethod( "getId", new Class[]{} ).invoke( puppetInst, new Object[]{} )
-		);
-		assertNotNull( puppetInst2 );
-		assertEquals(
-				"Barbie",
-				puppet.getMethod( "getName", new Class[]{} ).invoke( puppetInst, new Object[]{} )
-		);
-		s.delete( puppetInst2 );
-		s.getTransaction().commit();
-		s.close();
-		sf.close();
+		ArrayList list = new ArrayList();
+		List jars = new ArrayList();
+		addAnnotationJars(jars);
+		
+		new ExecuteContext(getOutputDir(), file, jars) {
+			
+		   protected void execute() throws Exception {
+			   
+			   AnnotationConfiguration configuration = new AnnotationConfiguration();
+				Class puppet = getUcl().loadClass( "org.hibernate.tool.hbm2x." + className );
+				configuration.addAnnotatedClass( puppet );
+				
+				configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
+				SessionFactory sf = configuration.buildSessionFactory();
+				Session s = sf.openSession();
 
-		currentThread.setContextClassLoader( ucl.getParent() );
-		TestHelper.deleteDir( file );
+				Object puppetInst = puppet.newInstance();
+				puppet.getMethod( "setName", new Class[]{String.class} ).invoke( puppetInst, new Object[]{"Barbie"} );
+				
+				if(className.equals("Bungalow")) { // hack to avoid not-null execption
+					puppet.getMethod("setMascot", new Class[] { puppet }).invoke( puppetInst, new Object[] { puppetInst } );
+				}
+				
+				s.getTransaction().begin();
+				s.persist( puppetInst );
+				s.getTransaction().commit();
+				s.clear();
+
+				s.getTransaction().begin();
+				Object puppetInst2 = s.get(
+						puppet,
+						(Serializable) puppet.getMethod( "getId", new Class[]{} ).invoke( puppetInst, new Object[]{} )
+				);
+				assertNotNull( puppetInst2 );
+				assertEquals(
+						"Barbie",
+						puppet.getMethod( "getName", new Class[]{} ).invoke( puppetInst, new Object[]{} )
+				);
+				s.delete( puppetInst2 );
+				s.getTransaction().commit();
+				s.close();
+				sf.close();
+				new SchemaExport(configuration).drop(false, true);
+			   
+		   };
+		   
+		}.run();
+		
 	}
 
+	private void addAnnotationJars(List jars) {
+		jars.add( "ejb3-persistence.jar" );
+		jars.add( "hibernate-annotations.jar" );
+		jars.add( "hibernate-commons-annotations.jar" );
+		jars.add( "hibernate3.jar" );
+		jars.add( "dom4j-1.6.1.jar" );
+		jars.add( "commons-logging-1.0.4.jar" );
+		
+	}
+
 	protected String getBaseForMappings() {
 		return "org/hibernate/tool/hbm2x/";
 	}
@@ -242,9 +337,11 @@
 				"Bungalow.hbm.xml"
 		};
 	}
+	
+	
 
 	protected void tearDown() throws Exception {
 		// TODO Auto-generated method stub
-		//super.tearDown();
+		super.tearDown();
 	}
 }




More information about the hibernate-commits mailing list