Hibernate SVN: r10731 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 12:50:54 -0500 (Mon, 06 Nov 2006)
New Revision: 10731
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
Log:
Configuration : javadocs and general code cleanup
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-11-06 17:50:37 UTC (rev 10730)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-11-06 17:50:54 UTC (rev 10731)
@@ -29,208 +29,224 @@
public class MappingExceptionTest extends TestCase {
public MappingExceptionTest(String name) {
- super(name);
+ super( name );
}
protected String[] getMappings() {
- return new String[] {"mappingexception/User.hbm.xml"};
+ return new String[] { "mappingexception/User.hbm.xml" };
}
public void testNotFound() throws MappingException, MalformedURLException {
-
+
try {
getCfg().addCacheableFile( "completelybogus.hbm.xml" );
fail();
- } catch(InvalidMappingException inv) { // TODO: should be MappingNotFound
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
}
-
+ catch ( MappingNotFoundException e ) {
+ assertEquals( e.getType(), "file" );
+ assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+ }
+
try {
- getCfg().addCacheableFile( new File("completelybogus.hbm.xml") );
+ getCfg().addCacheableFile( new File( "completelybogus.hbm.xml" ) );
fail();
- } catch(InvalidMappingException inv) { // TODO: should be MappingNotFound
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
}
+ catch ( MappingNotFoundException e ) {
+ assertEquals( e.getType(), "file" );
+ assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+ }
try {
getCfg().addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
fail();
- } catch(MappingNotFoundException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "org/hibernate/Hibernate.hbm.xml");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "org/hibernate/Hibernate.hbm.xml" );
+ }
+
try {
- getCfg().addFile( "completelybogus.hbm.xml" );
+ getCfg().addFile( "completelybogus.hbm.xml" );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
}
-
+ catch ( MappingNotFoundException e ) {
+ assertEquals( e.getType(), "file" );
+ assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+ }
+
try {
- getCfg().addFile( new File("completelybogus.hbm.xml"));
+ getCfg().addFile( new File( "completelybogus.hbm.xml" ) );
fail();
- } catch(InvalidMappingException inv) { // TODO: could be a MappingNotFoundException
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertEquals( inv.getPath(), "completelybogus.hbm.xml" );
+ }
+
try {
- getCfg().addInputStream( new ByteArrayInputStream(new byte[0]));
+ getCfg().addInputStream( new ByteArrayInputStream( new byte[0] ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "input stream");
- assertEquals(inv.getPath(), null);
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "input stream" );
+ assertEquals( inv.getPath(), null );
+ }
+
try {
getCfg().addResource( "nothere" );
fail();
- } catch(MappingNotFoundException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "nothere");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "nothere" );
+ }
+
try {
getCfg().addResource( "nothere", getClass().getClassLoader() );
fail();
- } catch(MappingNotFoundException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "nothere");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "nothere" );
+ }
+
try {
- getCfg().addURL( new URL("file://nothere") );
+ getCfg().addURL( new URL( "file://nothere" ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "URL");
- assertEquals(inv.getPath(), "file://nothere");
- }
+ }
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "URL" );
+ assertEquals( inv.getPath(), "file://nothere" );
+ }
}
-
+
public void testDuplicateMapping() {
try {
getCfg().addResource( getBaseForMappings() + "mappingexception/User.hbm.xml" );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class);
}
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml" );
+ assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
+ }
}
-
- void copy(InputStream in, File dst) throws IOException {
- OutputStream out = new FileOutputStream(dst);
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- }
-
+
+ void copy(InputStream in, File dst) throws IOException {
+ OutputStream out = new FileOutputStream( dst );
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ( ( len = in.read( buf ) ) > 0 ) {
+ out.write( buf, 0, len );
+ }
+ in.close();
+ out.close();
+ }
+
public void testInvalidMapping() throws MappingException, IOException {
String resourceName = getBaseForMappings() + "mappingexception/InvalidMapping.hbm.xml";
-
+
File file = File.createTempFile( "TempInvalidMapping", ".hbm.xml" );
file.deleteOnExit();
copy( ConfigHelper.getConfigStream( resourceName ), file );
-
+
try {
getCfg().addCacheableFile( file.getAbsolutePath() );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertNotNull(inv.getPath());
- assertTrue(inv.getPath().endsWith(".hbm.xml"));
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertNotNull( inv.getPath() );
+ assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addCacheableFile( file );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertNotNull(inv.getPath());
- assertTrue(inv.getPath().endsWith(".hbm.xml"));
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertNotNull( inv.getPath() );
+ assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
try {
- getCfg().addClass( InvalidMapping.class );
+ getCfg().addClass( InvalidMapping.class );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml");
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml" );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
- getCfg().addFile( file.getAbsolutePath() );
+ getCfg().addFile( file.getAbsolutePath() );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), file.getPath());
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertEquals( inv.getPath(), file.getPath() );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
- getCfg().addFile( file );
+ getCfg().addFile( file );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), file.getPath());
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertEquals( inv.getPath(), file.getPath() );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
+
try {
- getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
+ getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "input stream");
- assertEquals(inv.getPath(), null);
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "input stream" );
+ assertEquals( inv.getPath(), null );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addResource( resourceName );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), resourceName);
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), resourceName );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addResource( resourceName, getClass().getClassLoader() );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), resourceName);
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), resourceName );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addURL( ConfigHelper.findAsResource( resourceName ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "URL");
- assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml"));
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
- }
+ }
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "URL" );
+ assertTrue( inv.getPath().endsWith( "InvalidMapping.hbm.xml" ) );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
}
-
+
public static Test suite() {
- return new TestSuite(MappingExceptionTest.class);
+ return new TestSuite( MappingExceptionTest.class );
}
}
18 years, 2 months
Hibernate SVN: r10730 - branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 12:50:37 -0500 (Mon, 06 Nov 2006)
New Revision: 10730
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
Log:
Configuration : javadocs and general code cleanup
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-06 17:43:53 UTC (rev 10729)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-06 17:50:37 UTC (rev 10730)
@@ -192,7 +192,9 @@
}
/**
- * Iterate the class mappings
+ * Iterate the entity mappings
+ *
+ * @return Iterator of the entity mappings currently contained in the configuration.
*/
public Iterator getClassMappings() {
return classes.values().iterator();
@@ -200,6 +202,8 @@
/**
* Iterate the collection mappings
+ *
+ * @return Iterator of the collection mappings currently contained in the configuration.
*/
public Iterator getCollectionMappings() {
return collections.values().iterator();
@@ -207,23 +211,28 @@
/**
* Iterate the table mappings
+ *
+ * @return Iterator of the table mappings currently contained in the configuration.
*/
public Iterator getTableMappings() {
return tables.values().iterator();
}
/**
- * Get the mapping for a particular class
+ * Get the mapping for a particular entity
+ *
+ * @param entityName An entity name.
+ * @return the entity mapping information
*/
- public PersistentClass getClassMapping(String persistentClass) {
- return (PersistentClass) classes.get( persistentClass );
+ public PersistentClass getClassMapping(String entityName) {
+ return (PersistentClass) classes.get( entityName );
}
/**
* Get the mapping for a particular collection role
*
* @param role a collection role
- * @return Collection
+ * @return The collection mapping information
*/
public Collection getCollectionMapping(String role) {
return (Collection) collections.get( role );
@@ -269,43 +278,46 @@
* Read mappings from a particular XML file
*
* @param xmlFile a path to a file
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates inability to locate or parse
+ * the specified mapping file.
+ * @see #addFile(java.io.File)
*/
public Configuration addFile(String xmlFile) throws MappingException {
- log.info( "Reading mappings from file: " + xmlFile );
- try {
- File file = new File( xmlFile );
- if(file.exists()) {
- List errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile, errors, entityResolver )
- .read( file );
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
- }
- add( doc );
- return this;
- } else {
- throw new MappingNotFoundException("file", file.toString());
- }
- }
- catch (Exception e) {
- throw new InvalidMappingException("file", xmlFile, e);
- }
+ return addFile( new File( xmlFile ) );
}
/**
* Read mappings from a particular XML file
*
* @param xmlFile a path to a file
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates inability to locate or parse
+ * the specified mapping file.
*/
public Configuration addFile(File xmlFile) throws MappingException {
log.info( "Reading mappings from file: " + xmlFile.getPath() );
+ if ( !xmlFile.exists() ) {
+ throw new MappingNotFoundException( "file", xmlFile.toString() );
+ }
try {
- addInputStream( new FileInputStream( xmlFile ) );
+ List errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile.toString(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), ( Throwable ) errors.get( 0 ) );
+ }
+ add( doc );
+ return this;
}
- catch (Exception e) {
- throw new InvalidMappingException( "file", xmlFile.getPath(),e );
+ catch ( InvalidMappingException e ) {
+ throw e;
}
- return this;
+ catch ( MappingNotFoundException e ) {
+ throw e;
+ }
+ catch ( Exception e ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), e );
+ }
}
/**
@@ -410,6 +422,9 @@
* Read mappings from a <tt>String</tt>
*
* @param xml an XML string
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates problems parsing the
+ * given XML string
*/
public Configuration addXML(String xml) throws MappingException {
if ( log.isDebugEnabled() ) {
@@ -433,17 +448,23 @@
/**
* Read mappings from a <tt>URL</tt>
*
- * @param url
+ * @param url The url for the mapping document to be read.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the URL or processing
+ * the mapping document.
*/
public Configuration addURL(URL url) throws MappingException {
if ( log.isDebugEnabled() ) {
- log.debug( "Reading mapping document from URL:" + url );
+ log.debug( "Reading mapping document from URL:" + url.toExternalForm() );
}
try {
addInputStream( url.openStream() );
}
+ catch ( InvalidMappingException e ) {
+ throw new InvalidMappingException( "URL", url.toExternalForm(), e.getCause() );
+ }
catch (Exception e) {
- throw new InvalidMappingException( "URL", ""+url, e );
+ throw new InvalidMappingException( "URL", url.toExternalForm(), e );
}
return this;
}
@@ -451,7 +472,10 @@
/**
* Read mappings from a DOM <tt>Document</tt>
*
- * @param doc a DOM document
+ * @param doc The DOM document
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the DOM or processing
+ * the mapping document.
*/
public Configuration addDocument(Document doc) throws MappingException {
if ( log.isDebugEnabled() ) {
@@ -461,39 +485,13 @@
return this;
}
- protected void add(org.dom4j.Document doc) throws MappingException {
- HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
- }
-
/**
- * Create a new <tt>Mappings</tt> to add class and collection
- * mappings to.
- */
- public Mappings createMappings() {
- return new Mappings(
- classes,
- collections,
- tables,
- namedQueries,
- namedSqlQueries,
- sqlResultSetMappings,
- imports,
- secondPasses,
- propertyReferences,
- namingStrategy,
- typeDefs,
- filterDefinitions,
- extendsQueue,
- auxiliaryDatabaseObjects,
- tableNameBinding,
- columnNameBindingPerTable
- );
- }
-
- /**
- * Read mappings from an <tt>InputStream</tt>
+ * Read mappings from an {@link java.io.InputStream}.
*
- * @param xmlInputStream an <tt>InputStream</tt> containing XML
+ * @param xmlInputStream The input stream containing a DOM.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the stream, or
+ * processing the contained mapping document.
*/
public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
try {
@@ -501,7 +499,7 @@
org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, entityResolver )
.read( new InputSource( xmlInputStream ) );
if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
+ throw new InvalidMappingException( "invalid mapping", null, (Throwable) errors.get( 0 ) );
}
add( doc );
return this;
@@ -520,85 +518,88 @@
}
/**
- * Read mappings from an application resource
+ * Read mappings as a application resource (i.e. classpath lookup).
*
- * @param path a resource
- * @param classLoader a <tt>ClassLoader</tt> to use
+ * @param resourceName The resource name
+ * @param classLoader The class loader to use.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
*/
- public Configuration addResource(String path, ClassLoader classLoader) throws MappingException {
- log.info( "Reading mappings from resource: " + path );
- InputStream rsrc = classLoader.getResourceAsStream( path );
+ public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
+ log.info( "Reading mappings from resource: " + resourceName );
+ InputStream rsrc = classLoader.getResourceAsStream( resourceName );
if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", path );
+ throw new MappingNotFoundException( "resource", resourceName );
}
try {
return addInputStream( rsrc );
}
catch (MappingException me) {
- throw new InvalidMappingException( "resource", path, me );
+ throw new InvalidMappingException( "resource", resourceName, me );
}
}
/**
- * Read mappings from an application resource trying different classloaders.
- * This method will try to load the resource first from the thread context
- * classloader and then from the classloader that loaded Hibernate.
+ * Read mappings as a application resourceName (i.e. classpath lookup)
+ * trying different classloaders.
+ *
+ * @param resourceName The resource name
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
*/
- public Configuration addResource(String path) throws MappingException {
- log.info( "Reading mappings from resource: " + path );
+ public Configuration addResource(String resourceName) throws MappingException {
+ log.info( "Reading mappings from resource : " + resourceName );
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
InputStream rsrc = null;
if (contextClassLoader!=null) {
- rsrc = contextClassLoader.getResourceAsStream( path );
+ rsrc = contextClassLoader.getResourceAsStream( resourceName );
}
if ( rsrc == null ) {
- rsrc = Environment.class.getClassLoader().getResourceAsStream( path );
+ rsrc = Environment.class.getClassLoader().getResourceAsStream( resourceName );
}
if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", path );
+ throw new MappingNotFoundException( "resource", resourceName );
}
try {
return addInputStream( rsrc );
}
catch (MappingException me) {
- throw new InvalidMappingException( "resource", path, me );
+ throw new InvalidMappingException( "resource", resourceName, me );
}
}
/**
- * Read a mapping from an application resource, using a convention.
- * The class <tt>foo.bar.Foo</tt> is mapped by the file <tt>foo/bar/Foo.hbm.xml</tt>.
+ * Read a mapping as an application resouurce using the convention that a class
+ * named <tt>foo.bar.Foo</tt> is mapped by a file <tt>foo/bar/Foo.hbm.xml</tt>
+ * which can be resolved as a classpath resource.
*
- * @param persistentClass the mapped class
+ * @param persistentClass The mapped class
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
*/
public Configuration addClass(Class persistentClass) throws MappingException {
- String fileName = persistentClass.getName().replace( '.', '/' ) + ".hbm.xml";
- log.info( "Reading mappings from resource: " + fileName );
- InputStream rsrc = persistentClass.getClassLoader().getResourceAsStream( fileName );
- if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", fileName );
- }
- try {
- return addInputStream( rsrc );
- }
- catch (MappingException me) {
- throw new InvalidMappingException(
- "resource", fileName, me );
- }
+ String mappingResourceName = persistentClass.getName().replace( '.', '/' ) + ".hbm.xml";
+ log.info( "Reading mappings from resource: " + mappingResourceName );
+ return addResource( mappingResourceName, persistentClass.getClassLoader() );
}
/**
* Read all mappings from a jar file
+ * <p/>
+ * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
*
* @param jar a jar file
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the jar file or
+ * processing the contained mapping documents.
*/
public Configuration addJar(File jar) throws MappingException {
-
log.info( "Searching for mapping documents in jar: " + jar.getName() );
-
JarFile jarFile = null;
try {
-
try {
jarFile = new JarFile( jar );
}
@@ -606,14 +607,11 @@
throw new InvalidMappingException(
"Could not read mapping documents from jar: " + jar.getName(), "jar", jar.getName(),
ioe
- );
+ );
}
-
Enumeration jarEntries = jarFile.entries();
while ( jarEntries.hasMoreElements() ) {
-
ZipEntry ze = (ZipEntry) jarEntries.nextElement();
-
if ( ze.getName().endsWith( ".hbm.xml" ) ) {
log.info( "Found mapping document in jar: " + ze.getName() );
try {
@@ -621,18 +619,16 @@
}
catch (Exception e) {
throw new InvalidMappingException(
- "Could not read mapping documents from jar: " + jar.getName(),
- "jar",
- jar.getName(),
+ "Could not read mapping documents from jar: " + jar.getName(),
+ "jar",
+ jar.getName(),
e
- );
+ );
}
}
}
-
}
finally {
-
try {
if ( jarFile != null ) {
jarFile.close();
@@ -641,18 +637,20 @@
catch (IOException ioe) {
log.error("could not close jar", ioe);
}
-
}
return this;
-
}
/**
- * Read all mapping documents from a directory tree. Assume that any
- * file named <tt>*.hbm.xml</tt> is a mapping document.
+ * Read all mapping documents from a directory tree.
+ * <p/>
+ * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
*
- * @param dir a directory
+ * @param dir The directory
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the jar file or
+ * processing the contained mapping documents.
*/
public Configuration addDirectory(File dir) throws MappingException {
File[] files = dir.listFiles();
@@ -667,6 +665,36 @@
return this;
}
+ protected void add(org.dom4j.Document doc) throws MappingException {
+ HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
+ }
+
+ /**
+ * Create a new <tt>Mappings</tt> to add class and collection
+ * mappings to.
+ */
+ public Mappings createMappings() {
+ return new Mappings(
+ classes,
+ collections,
+ tables,
+ namedQueries,
+ namedSqlQueries,
+ sqlResultSetMappings,
+ imports,
+ secondPasses,
+ propertyReferences,
+ namingStrategy,
+ typeDefs,
+ filterDefinitions,
+ extendsQueue,
+ auxiliaryDatabaseObjects,
+ tableNameBinding,
+ columnNameBindingPerTable
+ );
+ }
+
+
private Iterator iterateGenerators(Dialect dialect) throws MappingException {
TreeMap generators = new TreeMap();
18 years, 2 months
Hibernate SVN: r10729 - trunk/Hibernate3/test/org/hibernate/test/mappingexception
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 12:43:53 -0500 (Mon, 06 Nov 2006)
New Revision: 10729
Modified:
trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
Log:
Configuration : javadocs and general code cleanup
Modified: trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-11-06 17:43:39 UTC (rev 10728)
+++ trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java 2006-11-06 17:43:53 UTC (rev 10729)
@@ -29,208 +29,224 @@
public class MappingExceptionTest extends TestCase {
public MappingExceptionTest(String name) {
- super(name);
+ super( name );
}
protected String[] getMappings() {
- return new String[] {"mappingexception/User.hbm.xml"};
+ return new String[] { "mappingexception/User.hbm.xml" };
}
public void testNotFound() throws MappingException, MalformedURLException {
-
+
try {
getCfg().addCacheableFile( "completelybogus.hbm.xml" );
fail();
- } catch(InvalidMappingException inv) { // TODO: should be MappingNotFound
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
}
-
+ catch ( MappingNotFoundException e ) {
+ assertEquals( e.getType(), "file" );
+ assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+ }
+
try {
- getCfg().addCacheableFile( new File("completelybogus.hbm.xml") );
+ getCfg().addCacheableFile( new File( "completelybogus.hbm.xml" ) );
fail();
- } catch(InvalidMappingException inv) { // TODO: should be MappingNotFound
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
}
+ catch ( MappingNotFoundException e ) {
+ assertEquals( e.getType(), "file" );
+ assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+ }
try {
getCfg().addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
fail();
- } catch(MappingNotFoundException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "org/hibernate/Hibernate.hbm.xml");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "org/hibernate/Hibernate.hbm.xml" );
+ }
+
try {
- getCfg().addFile( "completelybogus.hbm.xml" );
+ getCfg().addFile( "completelybogus.hbm.xml" );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
}
-
+ catch ( MappingNotFoundException e ) {
+ assertEquals( e.getType(), "file" );
+ assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+ }
+
try {
- getCfg().addFile( new File("completelybogus.hbm.xml"));
+ getCfg().addFile( new File( "completelybogus.hbm.xml" ) );
fail();
- } catch(InvalidMappingException inv) { // TODO: could be a MappingNotFoundException
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), "completelybogus.hbm.xml");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertEquals( inv.getPath(), "completelybogus.hbm.xml" );
+ }
+
try {
- getCfg().addInputStream( new ByteArrayInputStream(new byte[0]));
+ getCfg().addInputStream( new ByteArrayInputStream( new byte[0] ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "input stream");
- assertEquals(inv.getPath(), null);
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "input stream" );
+ assertEquals( inv.getPath(), null );
+ }
+
try {
getCfg().addResource( "nothere" );
fail();
- } catch(MappingNotFoundException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "nothere");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "nothere" );
+ }
+
try {
getCfg().addResource( "nothere", getClass().getClassLoader() );
fail();
- } catch(MappingNotFoundException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "nothere");
}
-
+ catch ( MappingNotFoundException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "nothere" );
+ }
+
try {
- getCfg().addURL( new URL("file://nothere") );
+ getCfg().addURL( new URL( "file://nothere" ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "URL");
- assertEquals(inv.getPath(), "file://nothere");
- }
+ }
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "URL" );
+ assertEquals( inv.getPath(), "file://nothere" );
+ }
}
-
+
public void testDuplicateMapping() {
try {
getCfg().addResource( getBaseForMappings() + "mappingexception/User.hbm.xml" );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml");
- assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class);
}
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml" );
+ assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
+ }
}
-
- void copy(InputStream in, File dst) throws IOException {
- OutputStream out = new FileOutputStream(dst);
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- }
-
+
+ void copy(InputStream in, File dst) throws IOException {
+ OutputStream out = new FileOutputStream( dst );
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ( ( len = in.read( buf ) ) > 0 ) {
+ out.write( buf, 0, len );
+ }
+ in.close();
+ out.close();
+ }
+
public void testInvalidMapping() throws MappingException, IOException {
String resourceName = getBaseForMappings() + "mappingexception/InvalidMapping.hbm.xml";
-
+
File file = File.createTempFile( "TempInvalidMapping", ".hbm.xml" );
file.deleteOnExit();
copy( ConfigHelper.getConfigStream( resourceName ), file );
-
+
try {
getCfg().addCacheableFile( file.getAbsolutePath() );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertNotNull(inv.getPath());
- assertTrue(inv.getPath().endsWith(".hbm.xml"));
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertNotNull( inv.getPath() );
+ assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addCacheableFile( file );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertNotNull(inv.getPath());
- assertTrue(inv.getPath().endsWith(".hbm.xml"));
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertNotNull( inv.getPath() );
+ assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
try {
- getCfg().addClass( InvalidMapping.class );
+ getCfg().addClass( InvalidMapping.class );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml");
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml" );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
- getCfg().addFile( file.getAbsolutePath() );
+ getCfg().addFile( file.getAbsolutePath() );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), file.getPath());
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertEquals( inv.getPath(), file.getPath() );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
- getCfg().addFile( file );
+ getCfg().addFile( file );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "file");
- assertEquals(inv.getPath(), file.getPath());
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "file" );
+ assertEquals( inv.getPath(), file.getPath() );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
+
try {
- getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
+ getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "input stream");
- assertEquals(inv.getPath(), null);
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "input stream" );
+ assertEquals( inv.getPath(), null );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addResource( resourceName );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), resourceName);
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), resourceName );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addResource( resourceName, getClass().getClassLoader() );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "resource");
- assertEquals(inv.getPath(), resourceName);
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
}
-
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "resource" );
+ assertEquals( inv.getPath(), resourceName );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
+
try {
getCfg().addURL( ConfigHelper.findAsResource( resourceName ) );
fail();
- } catch(InvalidMappingException inv) {
- assertEquals(inv.getType(), "URL");
- assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml"));
- assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
- }
+ }
+ catch ( InvalidMappingException inv ) {
+ assertEquals( inv.getType(), "URL" );
+ assertTrue( inv.getPath().endsWith( "InvalidMapping.hbm.xml" ) );
+ assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+ }
}
-
+
public static Test suite() {
- return new TestSuite(MappingExceptionTest.class);
+ return new TestSuite( MappingExceptionTest.class );
}
}
18 years, 2 months
Hibernate SVN: r10728 - trunk/Hibernate3/src/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 12:43:39 -0500 (Mon, 06 Nov 2006)
New Revision: 10728
Modified:
trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java
Log:
Configuration : javadocs and general code cleanup
Modified: trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-06 16:03:49 UTC (rev 10727)
+++ trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-06 17:43:39 UTC (rev 10728)
@@ -180,8 +180,8 @@
private transient Mapping mapping = buildMapping();
-
+
protected Configuration(SettingsFactory settingsFactory) {
this.settingsFactory = settingsFactory;
reset();
@@ -192,7 +192,9 @@
}
/**
- * Iterate the class mappings
+ * Iterate the entity mappings
+ *
+ * @return Iterator of the entity mappings currently contained in the configuration.
*/
public Iterator getClassMappings() {
return classes.values().iterator();
@@ -200,6 +202,8 @@
/**
* Iterate the collection mappings
+ *
+ * @return Iterator of the collection mappings currently contained in the configuration.
*/
public Iterator getCollectionMappings() {
return collections.values().iterator();
@@ -207,23 +211,28 @@
/**
* Iterate the table mappings
+ *
+ * @return Iterator of the table mappings currently contained in the configuration.
*/
public Iterator getTableMappings() {
return tables.values().iterator();
}
/**
- * Get the mapping for a particular class
+ * Get the mapping for a particular entity
+ *
+ * @param entityName An entity name.
+ * @return the entity mapping information
*/
- public PersistentClass getClassMapping(String persistentClass) {
- return (PersistentClass) classes.get( persistentClass );
+ public PersistentClass getClassMapping(String entityName) {
+ return (PersistentClass) classes.get( entityName );
}
/**
* Get the mapping for a particular collection role
*
* @param role a collection role
- * @return Collection
+ * @return The collection mapping information
*/
public Collection getCollectionMapping(String role) {
return (Collection) collections.get( role );
@@ -269,43 +278,46 @@
* Read mappings from a particular XML file
*
* @param xmlFile a path to a file
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates inability to locate or parse
+ * the specified mapping file.
+ * @see #addFile(java.io.File)
*/
public Configuration addFile(String xmlFile) throws MappingException {
- log.info( "Reading mappings from file: " + xmlFile );
- try {
- File file = new File( xmlFile );
- if(file.exists()) {
- List errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile, errors, entityResolver )
- .read( file );
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
- }
- add( doc );
- return this;
- } else {
- throw new MappingNotFoundException("file", file.toString());
- }
- }
- catch (Exception e) {
- throw new InvalidMappingException("file", xmlFile, e);
- }
+ return addFile( new File( xmlFile ) );
}
/**
* Read mappings from a particular XML file
*
* @param xmlFile a path to a file
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates inability to locate or parse
+ * the specified mapping file.
*/
public Configuration addFile(File xmlFile) throws MappingException {
log.info( "Reading mappings from file: " + xmlFile.getPath() );
+ if ( !xmlFile.exists() ) {
+ throw new MappingNotFoundException( "file", xmlFile.toString() );
+ }
try {
- addInputStream( new FileInputStream( xmlFile ) );
+ List errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile.toString(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), ( Throwable ) errors.get( 0 ) );
+ }
+ add( doc );
+ return this;
}
- catch (Exception e) {
- throw new InvalidMappingException( "file", xmlFile.getPath(),e );
+ catch ( InvalidMappingException e ) {
+ throw e;
}
- return this;
+ catch ( MappingNotFoundException e ) {
+ throw e;
+ }
+ catch ( Exception e ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), e );
+ }
}
/**
@@ -410,6 +422,9 @@
* Read mappings from a <tt>String</tt>
*
* @param xml an XML string
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates problems parsing the
+ * given XML string
*/
public Configuration addXML(String xml) throws MappingException {
if ( log.isDebugEnabled() ) {
@@ -433,17 +448,23 @@
/**
* Read mappings from a <tt>URL</tt>
*
- * @param url
+ * @param url The url for the mapping document to be read.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the URL or processing
+ * the mapping document.
*/
public Configuration addURL(URL url) throws MappingException {
if ( log.isDebugEnabled() ) {
- log.debug( "Reading mapping document from URL:" + url );
+ log.debug( "Reading mapping document from URL:" + url.toExternalForm() );
}
try {
addInputStream( url.openStream() );
}
+ catch ( InvalidMappingException e ) {
+ throw new InvalidMappingException( "URL", url.toExternalForm(), e.getCause() );
+ }
catch (Exception e) {
- throw new InvalidMappingException( "URL", ""+url, e );
+ throw new InvalidMappingException( "URL", url.toExternalForm(), e );
}
return this;
}
@@ -451,7 +472,10 @@
/**
* Read mappings from a DOM <tt>Document</tt>
*
- * @param doc a DOM document
+ * @param doc The DOM document
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the DOM or processing
+ * the mapping document.
*/
public Configuration addDocument(Document doc) throws MappingException {
if ( log.isDebugEnabled() ) {
@@ -461,39 +485,13 @@
return this;
}
- protected void add(org.dom4j.Document doc) throws MappingException {
- HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
- }
-
/**
- * Create a new <tt>Mappings</tt> to add class and collection
- * mappings to.
- */
- public Mappings createMappings() {
- return new Mappings(
- classes,
- collections,
- tables,
- namedQueries,
- namedSqlQueries,
- sqlResultSetMappings,
- imports,
- secondPasses,
- propertyReferences,
- namingStrategy,
- typeDefs,
- filterDefinitions,
- extendsQueue,
- auxiliaryDatabaseObjects,
- tableNameBinding,
- columnNameBindingPerTable
- );
- }
-
- /**
- * Read mappings from an <tt>InputStream</tt>
+ * Read mappings from an {@link java.io.InputStream}.
*
- * @param xmlInputStream an <tt>InputStream</tt> containing XML
+ * @param xmlInputStream The input stream containing a DOM.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the stream, or
+ * processing the contained mapping document.
*/
public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
try {
@@ -501,7 +499,7 @@
org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, entityResolver )
.read( new InputSource( xmlInputStream ) );
if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
+ throw new InvalidMappingException( "invalid mapping", null, (Throwable) errors.get( 0 ) );
}
add( doc );
return this;
@@ -520,85 +518,88 @@
}
/**
- * Read mappings from an application resource
+ * Read mappings as a application resource (i.e. classpath lookup).
*
- * @param path a resource
- * @param classLoader a <tt>ClassLoader</tt> to use
+ * @param resourceName The resource name
+ * @param classLoader The class loader to use.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
*/
- public Configuration addResource(String path, ClassLoader classLoader) throws MappingException {
- log.info( "Reading mappings from resource: " + path );
- InputStream rsrc = classLoader.getResourceAsStream( path );
+ public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
+ log.info( "Reading mappings from resource: " + resourceName );
+ InputStream rsrc = classLoader.getResourceAsStream( resourceName );
if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", path );
+ throw new MappingNotFoundException( "resource", resourceName );
}
try {
return addInputStream( rsrc );
}
catch (MappingException me) {
- throw new InvalidMappingException( "resource", path, me );
+ throw new InvalidMappingException( "resource", resourceName, me );
}
}
/**
- * Read mappings from an application resource trying different classloaders.
- * This method will try to load the resource first from the thread context
- * classloader and then from the classloader that loaded Hibernate.
+ * Read mappings as a application resourceName (i.e. classpath lookup)
+ * trying different classloaders.
+ *
+ * @param resourceName The resource name
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
*/
- public Configuration addResource(String path) throws MappingException {
- log.info( "Reading mappings from resource: " + path );
+ public Configuration addResource(String resourceName) throws MappingException {
+ log.info( "Reading mappings from resource : " + resourceName );
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
InputStream rsrc = null;
if (contextClassLoader!=null) {
- rsrc = contextClassLoader.getResourceAsStream( path );
+ rsrc = contextClassLoader.getResourceAsStream( resourceName );
}
if ( rsrc == null ) {
- rsrc = Environment.class.getClassLoader().getResourceAsStream( path );
+ rsrc = Environment.class.getClassLoader().getResourceAsStream( resourceName );
}
if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", path );
+ throw new MappingNotFoundException( "resource", resourceName );
}
try {
return addInputStream( rsrc );
}
catch (MappingException me) {
- throw new InvalidMappingException( "resource", path, me );
+ throw new InvalidMappingException( "resource", resourceName, me );
}
}
/**
- * Read a mapping from an application resource, using a convention.
- * The class <tt>foo.bar.Foo</tt> is mapped by the file <tt>foo/bar/Foo.hbm.xml</tt>.
+ * Read a mapping as an application resouurce using the convention that a class
+ * named <tt>foo.bar.Foo</tt> is mapped by a file <tt>foo/bar/Foo.hbm.xml</tt>
+ * which can be resolved as a classpath resource.
*
- * @param persistentClass the mapped class
+ * @param persistentClass The mapped class
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
*/
public Configuration addClass(Class persistentClass) throws MappingException {
- String fileName = persistentClass.getName().replace( '.', '/' ) + ".hbm.xml";
- log.info( "Reading mappings from resource: " + fileName );
- InputStream rsrc = persistentClass.getClassLoader().getResourceAsStream( fileName );
- if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", fileName );
- }
- try {
- return addInputStream( rsrc );
- }
- catch (MappingException me) {
- throw new InvalidMappingException(
- "resource", fileName, me );
- }
+ String mappingResourceName = persistentClass.getName().replace( '.', '/' ) + ".hbm.xml";
+ log.info( "Reading mappings from resource: " + mappingResourceName );
+ return addResource( mappingResourceName, persistentClass.getClassLoader() );
}
/**
* Read all mappings from a jar file
+ * <p/>
+ * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
*
* @param jar a jar file
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the jar file or
+ * processing the contained mapping documents.
*/
public Configuration addJar(File jar) throws MappingException {
-
log.info( "Searching for mapping documents in jar: " + jar.getName() );
-
JarFile jarFile = null;
try {
-
try {
jarFile = new JarFile( jar );
}
@@ -606,14 +607,11 @@
throw new InvalidMappingException(
"Could not read mapping documents from jar: " + jar.getName(), "jar", jar.getName(),
ioe
- );
+ );
}
-
Enumeration jarEntries = jarFile.entries();
while ( jarEntries.hasMoreElements() ) {
-
ZipEntry ze = (ZipEntry) jarEntries.nextElement();
-
if ( ze.getName().endsWith( ".hbm.xml" ) ) {
log.info( "Found mapping document in jar: " + ze.getName() );
try {
@@ -621,18 +619,16 @@
}
catch (Exception e) {
throw new InvalidMappingException(
- "Could not read mapping documents from jar: " + jar.getName(),
- "jar",
- jar.getName(),
+ "Could not read mapping documents from jar: " + jar.getName(),
+ "jar",
+ jar.getName(),
e
- );
+ );
}
}
}
-
}
finally {
-
try {
if ( jarFile != null ) {
jarFile.close();
@@ -641,18 +637,20 @@
catch (IOException ioe) {
log.error("could not close jar", ioe);
}
-
}
return this;
-
}
/**
- * Read all mapping documents from a directory tree. Assume that any
- * file named <tt>*.hbm.xml</tt> is a mapping document.
+ * Read all mapping documents from a directory tree.
+ * <p/>
+ * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
*
- * @param dir a directory
+ * @param dir The directory
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the jar file or
+ * processing the contained mapping documents.
*/
public Configuration addDirectory(File dir) throws MappingException {
File[] files = dir.listFiles();
@@ -667,6 +665,36 @@
return this;
}
+ protected void add(org.dom4j.Document doc) throws MappingException {
+ HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
+ }
+
+ /**
+ * Create a new <tt>Mappings</tt> to add class and collection
+ * mappings to.
+ */
+ public Mappings createMappings() {
+ return new Mappings(
+ classes,
+ collections,
+ tables,
+ namedQueries,
+ namedSqlQueries,
+ sqlResultSetMappings,
+ imports,
+ secondPasses,
+ propertyReferences,
+ namingStrategy,
+ typeDefs,
+ filterDefinitions,
+ extendsQueue,
+ auxiliaryDatabaseObjects,
+ tableNameBinding,
+ columnNameBindingPerTable
+ );
+ }
+
+
private Iterator iterateGenerators(Dialect dialect) throws MappingException {
TreeMap generators = new TreeMap();
@@ -1096,7 +1124,7 @@
while ( iter.hasNext() ) {
SecondPass sp = (SecondPass) iter.next();
if ( ! (sp instanceof QuerySecondPass) ) {
- sp.doSecondPass( classes );
+ sp.doSecondPass( classes );
iter.remove();
}
}
@@ -1105,7 +1133,7 @@
iter = secondPasses.iterator();
while ( iter.hasNext() ) {
SecondPass sp = (SecondPass) iter.next();
- sp.doSecondPass( classes );
+ sp.doSecondPass( classes );
iter.remove();
}
@@ -2035,7 +2063,7 @@
Property prop = pc.getReferencedProperty( propertyName );
if ( prop == null ) {
throw new MappingException(
- "property not known: " +
+ "property not known: " +
persistentClass + '.' + propertyName
);
}
@@ -2065,7 +2093,7 @@
public Map getSqlFunctions() {
return sqlFunctions;
}
-
+
public void addSqlFunction(String functionName, SQLFunction function) {
sqlFunctions.put( functionName, function );
}
18 years, 2 months
Hibernate SVN: r10727 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 11:03:49 -0500 (Mon, 06 Nov 2006)
New Revision: 10727
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml
Log:
no idea
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml 2006-11-06 14:50:05 UTC (rev 10726)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/instrument/domain/Problematic.hbm.xml 2006-11-06 16:03:49 UTC (rev 10727)
@@ -1,14 +1,14 @@
- <?xml version="1.0"?>
- <!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<?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.test.instrument.domain">
- <class name="Problematic">
- <id name="id" type="long" column="ID">
- <generator class="increment" />
- </id>
- <property name="name" type="string" column="NAME" />
- <property name="bytes" type="org.hibernate.test.instrument.domain.CustomBlobType" column="DATA" lazy="true" />
- </class>
- </hibernate-mapping>
+<hibernate-mapping package="org.hibernate.test.instrument.domain">
+ <class name="Problematic">
+ <id name="id" type="long" column="ID">
+ <generator class="increment" />
+ </id>
+ <property name="name" type="string" column="NAME" />
+ <property name="bytes" type="org.hibernate.test.instrument.domain.CustomBlobType" column="DATA" lazy="true" />
+ </class>
+</hibernate-mapping>
18 years, 2 months
Hibernate SVN: r10726 - in trunk/Hibernate3/src/org/hibernate: mapping tool/hbm2ddl
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 09:50:05 -0500 (Mon, 06 Nov 2006)
New Revision: 10726
Modified:
trunk/Hibernate3/src/org/hibernate/mapping/Table.java
trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java
Log:
HHH-1629 schema update/validator quote handling (additional workaround for mysql)
merged from branch3_2
Modified: trunk/Hibernate3/src/org/hibernate/mapping/Table.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/mapping/Table.java 2006-11-06 14:35:20 UTC (rev 10725)
+++ trunk/Hibernate3/src/org/hibernate/mapping/Table.java 2006-11-06 14:50:05 UTC (rev 10726)
@@ -251,7 +251,7 @@
ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );
if ( columnInfo == null ) {
- throw new HibernateException( "Missing column: " + col.getName() );
+ throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
}
else {
final boolean typesMatch = col.getSqlType( dialect, mapping )
Modified: trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-06 14:35:20 UTC (rev 10725)
+++ trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-06 14:50:05 UTC (rev 10726)
@@ -60,8 +60,9 @@
try {
ResultSet rs = null;
try {
-
- if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
+ if ( (isQuoted && meta.storesMixedCaseQuotedIdentifiers())) {
+ rs = meta.getTables(catalog, schema, name, TYPES);
+ } else if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
|| (!isQuoted && meta.storesUpperCaseIdentifiers() )) {
rs = meta.getTables(
StringHelper.toUpperCase(catalog),
Modified: trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-06 14:35:20 UTC (rev 10725)
+++ trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-06 14:50:05 UTC (rev 10726)
@@ -48,6 +48,14 @@
return name;
}
+ public String getCatalog() {
+ return catalog;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
public String toString() {
return "TableMetadata(" + name + ')';
}
18 years, 2 months
Hibernate SVN: r10725 - in branches/Branch_3_2/Hibernate3/src/org/hibernate: mapping tool/hbm2ddl
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 09:35:20 -0500 (Mon, 06 Nov 2006)
New Revision: 10725
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/Table.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java
Log:
HHH-1629 schema update/validator quote handling (additional workaround for mysql)
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/Table.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/Table.java 2006-11-06 13:27:44 UTC (rev 10724)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/Table.java 2006-11-06 14:35:20 UTC (rev 10725)
@@ -251,7 +251,7 @@
ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );
if ( columnInfo == null ) {
- throw new HibernateException( "Missing column: " + col.getName() );
+ throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
}
else {
final boolean typesMatch = col.getSqlType( dialect, mapping )
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-06 13:27:44 UTC (rev 10724)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-06 14:35:20 UTC (rev 10725)
@@ -60,8 +60,9 @@
try {
ResultSet rs = null;
try {
-
- if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
+ if ( (isQuoted && meta.storesMixedCaseQuotedIdentifiers())) {
+ rs = meta.getTables(catalog, schema, name, TYPES);
+ } else if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
|| (!isQuoted && meta.storesUpperCaseIdentifiers() )) {
rs = meta.getTables(
StringHelper.toUpperCase(catalog),
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-06 13:27:44 UTC (rev 10724)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-06 14:35:20 UTC (rev 10725)
@@ -48,6 +48,14 @@
return name;
}
+ public String getCatalog() {
+ return catalog;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
public String toString() {
return "TableMetadata(" + name + ')';
}
18 years, 2 months
Hibernate SVN: r10724 - trunk/Hibernate3/src/org/hibernate/jdbc
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 08:27:44 -0500 (Mon, 06 Nov 2006)
New Revision: 10724
Modified:
trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
Log:
HHH-1737 : ConnectionWrapper
Modified: trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-06 13:27:28 UTC (rev 10723)
+++ trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-06 13:27:44 UTC (rev 10724)
@@ -29,6 +29,9 @@
this.connectionManager = connectionManager;
}
+ /**
+ * {@inheritDoc}
+ */
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ( "close".equals( method.getName() ) ) {
connectionManager.releaseBorrowedConnection();
@@ -51,15 +54,28 @@
}
}
+ /**
+ * Generates a Connection proxy wrapping the connection managed by the passed
+ * connection manager.
+ *
+ * @param connectionManager The connection manager to wrap with the
+ * connection proxy.
+ * @return The generated proxy.
+ */
public static Connection generateProxy(ConnectionManager connectionManager) {
BorrowedConnectionProxy handler = new BorrowedConnectionProxy( connectionManager );
return ( Connection ) Proxy.newProxyInstance(
- Connection.class.getClassLoader(),
+ getProxyClassLoader(),
PROXY_INTERFACES,
handler
);
}
+ /**
+ * Marks a borrowed connection as no longer usable.
+ *
+ * @param connection The connection (proxy) to be marked.
+ */
public static void renderUnuseable(Connection connection) {
if ( connection != null && Proxy.isProxyClass( connection.getClass() ) ) {
InvocationHandler handler = Proxy.getInvocationHandler( connection );
@@ -69,13 +85,33 @@
}
}
+ /**
+ * Convience method for unwrapping a connection proxy and getting a
+ * handle to an underlying connection.
+ *
+ * @param connection The connection (proxy) to be unwrapped.
+ * @return The unwrapped connection.
+ */
public static Connection getWrappedConnection(Connection connection) {
- if ( connection == null ) {
- return null;
+ if ( connection != null && connection instanceof ConnectionWrapper ) {
+ return ( ( ConnectionWrapper ) connection ).getWrappedConnection();
}
- if ( connection instanceof ConnectionWrapper ) {
- ( ( ConnectionWrapper ) connection ).getWrappedConnection();
+ else {
+ return connection;
}
- return connection;
}
+
+ /**
+ * Determines the appropriate class loader to which the generated proxy
+ * should be scoped.
+ *
+ * @return The class loader appropriate for proxy construction.
+ */
+ public static ClassLoader getProxyClassLoader() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if ( cl == null ) {
+ cl = BorrowedConnectionProxy.class.getClassLoader();
+ }
+ return cl;
+ }
}
18 years, 2 months
Hibernate SVN: r10723 - branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-06 08:27:28 -0500 (Mon, 06 Nov 2006)
New Revision: 10723
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
Log:
HHH-1737 : ConnectionWrapper
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-06 11:36:02 UTC (rev 10722)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-06 13:27:28 UTC (rev 10723)
@@ -29,6 +29,9 @@
this.connectionManager = connectionManager;
}
+ /**
+ * {@inheritDoc}
+ */
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ( "close".equals( method.getName() ) ) {
connectionManager.releaseBorrowedConnection();
@@ -51,15 +54,28 @@
}
}
+ /**
+ * Generates a Connection proxy wrapping the connection managed by the passed
+ * connection manager.
+ *
+ * @param connectionManager The connection manager to wrap with the
+ * connection proxy.
+ * @return The generated proxy.
+ */
public static Connection generateProxy(ConnectionManager connectionManager) {
BorrowedConnectionProxy handler = new BorrowedConnectionProxy( connectionManager );
return ( Connection ) Proxy.newProxyInstance(
- Connection.class.getClassLoader(),
+ getProxyClassLoader(),
PROXY_INTERFACES,
handler
);
}
+ /**
+ * Marks a borrowed connection as no longer usable.
+ *
+ * @param connection The connection (proxy) to be marked.
+ */
public static void renderUnuseable(Connection connection) {
if ( connection != null && Proxy.isProxyClass( connection.getClass() ) ) {
InvocationHandler handler = Proxy.getInvocationHandler( connection );
@@ -69,13 +85,33 @@
}
}
+ /**
+ * Convience method for unwrapping a connection proxy and getting a
+ * handle to an underlying connection.
+ *
+ * @param connection The connection (proxy) to be unwrapped.
+ * @return The unwrapped connection.
+ */
public static Connection getWrappedConnection(Connection connection) {
- if ( connection == null ) {
- return null;
+ if ( connection != null && connection instanceof ConnectionWrapper ) {
+ return ( ( ConnectionWrapper ) connection ).getWrappedConnection();
}
- if ( connection instanceof ConnectionWrapper ) {
- ( ( ConnectionWrapper ) connection ).getWrappedConnection();
+ else {
+ return connection;
}
- return connection;
}
+
+ /**
+ * Determines the appropriate class loader to which the generated proxy
+ * should be scoped.
+ *
+ * @return The class loader appropriate for proxy construction.
+ */
+ public static ClassLoader getProxyClassLoader() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if ( cl == null ) {
+ cl = BorrowedConnectionProxy.class.getClassLoader();
+ }
+ return cl;
+ }
}
18 years, 2 months
Hibernate SVN: r10722 - trunk/Hibernate3/test/org/hibernate/test/hql
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 06:36:02 -0500 (Mon, 06 Nov 2006)
New Revision: 10722
Modified:
trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
Updates for Ingres certification
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-11-06 11:35:51 UTC (rev 10721)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-11-06 11:36:02 UTC (rev 10722)
@@ -1623,7 +1623,9 @@
}
public void testSubselectBetween() {
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0);
+ if(supportsSubselectOnLeftSideIn()) {
+ assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0);
+ }
assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) between 0 and 100", 0);
assertResultSize("from Animal x where (select max(a.description) from Animal a) like 'big%'", 0);
assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) is not null", 0);
18 years, 2 months