Hibernate SVN: r10711 - trunk/Hibernate3/src/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 10:37:47 -0500 (Fri, 03 Nov 2006)
New Revision: 10711
Modified:
trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java
Log:
HHH-2108 : fixed cacheable files
Modified: trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 15:35:48 UTC (rev 10710)
+++ trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 15:37:47 UTC (rev 10711)
@@ -309,57 +309,98 @@
}
/**
- * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than <tt>xmlFile</tt> the
- * <tt>".bin"</tt> file will be read directly. Otherwise xmlFile is read and then
- * serialized to <tt>xmlFile + ".bin"</tt> for use the next time.
+ * Add a cached mapping file. A cached file is a serialized representation
+ * of the DOM structure of a particular mapping. It is saved from a previous
+ * call as a file with the name <tt>xmlFile + ".bin"</tt> where xmlFile is
+ * the name of the original mapping file.
+ * </p>
+ * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than
+ * <tt>xmlFile</tt> the <tt>".bin"</tt> file will be read directly. Otherwise
+ * xmlFile is read and then serialized to <tt>xmlFile + ".bin"</tt> for use
+ * the next time.
+ *
+ * @param xmlFile The cacheable mapping file to be added.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the cached file or processing
+ * the non-cached file.
*/
public Configuration addCacheableFile(File xmlFile) throws MappingException {
try {
- File lazyfile = new File( xmlFile.getAbsolutePath() + ".bin" );
+ File cachedFile = new File( xmlFile.getAbsolutePath() + ".bin" );
org.dom4j.Document doc = null;
- List errors = new ArrayList();
final boolean useCachedFile = xmlFile.exists() &&
- lazyfile.exists() &&
- xmlFile.lastModified() < lazyfile.lastModified();
+ cachedFile.exists() &&
+ xmlFile.lastModified() < cachedFile.lastModified();
if ( useCachedFile ) {
try {
- log.info( "Reading mappings from cache file: " + lazyfile );
- doc = (org.dom4j.Document) SerializationHelper.deserialize( new FileInputStream( lazyfile ) );
+ log.info( "Reading mappings from cache file: " + cachedFile );
+ doc = ( org.dom4j.Document ) SerializationHelper.deserialize( new FileInputStream( cachedFile ) );
}
- catch (SerializationException e) {
- log.warn( "Could not deserialize cache file: " + lazyfile.getPath(), e );
+ catch ( SerializationException e ) {
+ log.warn( "Could not deserialize cache file: " + cachedFile.getPath(), e );
}
+ catch ( FileNotFoundException e ) {
+ log.warn( "I/O reported cached file could not be found : " + cachedFile.getPath(), e );
+ }
}
- // If deserialization failed or cached file does not exist
- if ( doc == null && xmlFile.exists()) {
+ // if doc is null, then for whatever reason, the cached file cannot be used...
+ if ( doc == null ) {
+ if ( !xmlFile.exists() ) {
+ throw new MappingNotFoundException( "file", xmlFile.toString() );
+ }
+
log.info( "Reading mappings from file: " + xmlFile );
- doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver )
- .read( xmlFile );
+ List errors = new ArrayList();
try {
- log.debug( "Writing cache file for: " + xmlFile + " to: " + lazyfile );
- SerializationHelper.serialize( (Serializable) doc, new FileOutputStream( lazyfile ) );
+ doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );
+ }
}
- catch (SerializationException e) {
- log.warn( "Could not write cached file: " + lazyfile, e );
+ catch( DocumentException e){
+ throw new MappingException( "invalid mapping", e );
}
- } else {
- throw new MappingNotFoundException("file", xmlFile.toString());
+
+ try {
+ log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
+ SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStream( cachedFile ) );
+ }
+ catch ( SerializationException e ) {
+ log.warn( "Could not write cached file: " + cachedFile, e );
+ }
+ catch ( FileNotFoundException e ) {
+ log.warn( "I/O reported error writing cached file : " + cachedFile.getPath(), e );
+ }
}
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
- }
add( doc );
return this;
+
}
- catch (Exception e) {
- throw new InvalidMappingException("file", xmlFile.toString(), e);
+ catch ( InvalidMappingException e ) {
+ throw e;
}
+ catch ( MappingNotFoundException e ) {
+ throw e;
+ }
+ catch ( Exception e ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), e );
+ }
}
+ /**
+ * Add a cacheable mapping file.
+ *
+ * @param xmlFile The name of the file to be added. This must be in a form
+ * useable to simply construct a {@link java.io.File} instance.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the cached file or processing
+ * the non-cached file.
+ * @see #addCacheableFile(java.io.File)
+ */
public Configuration addCacheableFile(String xmlFile) throws MappingException {
return addCacheableFile( new File( xmlFile ) );
}
18 years, 2 months
Hibernate SVN: r10710 - branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 10:35:48 -0500 (Fri, 03 Nov 2006)
New Revision: 10710
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
Log:
HHH-2108 : fixed cacheable files
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-03 15:33:09 UTC (rev 10709)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 15:35:48 UTC (rev 10710)
@@ -309,14 +309,15 @@
}
/**
- * Add a cacheable mapping file. A cached file is a serialized representation
+ * Add a cached mapping file. A cached file is a serialized representation
* of the DOM structure of a particular mapping. It is saved from a previous
* call as a file with the name <tt>xmlFile + ".bin"</tt> where xmlFile is
* the name of the original mapping file.
* </p>
- * If a cached file exists and is newer than the incoming xml file, the cached
- * file will be read directly. Otherwise xmlFile is read (and cached in
- * serializable form for use next time) and used.
+ * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than
+ * <tt>xmlFile</tt> the <tt>".bin"</tt> file will be read directly. Otherwise
+ * xmlFile is read and then serialized to <tt>xmlFile + ".bin"</tt> for use
+ * the next time.
*
* @param xmlFile The cacheable mapping file to be added.
* @return this (for method chaining purposes)
@@ -340,6 +341,9 @@
catch ( SerializationException e ) {
log.warn( "Could not deserialize cache file: " + cachedFile.getPath(), e );
}
+ catch ( FileNotFoundException e ) {
+ log.warn( "I/O reported cached file could not be found : " + cachedFile.getPath(), e );
+ }
}
// if doc is null, then for whatever reason, the cached file cannot be used...
@@ -350,10 +354,15 @@
log.info( "Reading mappings from file: " + xmlFile );
List errors = new ArrayList();
- doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
+ try {
+ doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );
+ }
}
+ catch( DocumentException e){
+ throw new MappingException( "invalid mapping", e );
+ }
try {
log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
@@ -362,15 +371,21 @@
catch ( SerializationException e ) {
log.warn( "Could not write cached file: " + cachedFile, e );
}
+ catch ( FileNotFoundException e ) {
+ log.warn( "I/O reported error writing cached file : " + cachedFile.getPath(), e );
+ }
}
add( doc );
return this;
}
- catch ( MappingException e ) {
+ catch ( InvalidMappingException e ) {
throw e;
}
+ catch ( MappingNotFoundException e ) {
+ throw e;
+ }
catch ( Exception e ) {
throw new InvalidMappingException( "file", xmlFile.toString(), e );
}
18 years, 2 months
Hibernate SVN: r10709 - branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 10:33:09 -0500 (Fri, 03 Nov 2006)
New Revision: 10709
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
Log:
HHH-2108 : fixed cacheable files
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-03 15:32:55 UTC (rev 10708)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 15:33:09 UTC (rev 10709)
@@ -309,57 +309,83 @@
}
/**
- * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than <tt>xmlFile</tt> the
- * <tt>".bin"</tt> file will be read directly. Otherwise xmlFile is read and then
- * serialized to <tt>xmlFile + ".bin"</tt> for use the next time.
+ * Add a cacheable mapping file. A cached file is a serialized representation
+ * of the DOM structure of a particular mapping. It is saved from a previous
+ * call as a file with the name <tt>xmlFile + ".bin"</tt> where xmlFile is
+ * the name of the original mapping file.
+ * </p>
+ * If a cached file exists and is newer than the incoming xml file, the cached
+ * file will be read directly. Otherwise xmlFile is read (and cached in
+ * serializable form for use next time) and used.
+ *
+ * @param xmlFile The cacheable mapping file to be added.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the cached file or processing
+ * the non-cached file.
*/
public Configuration addCacheableFile(File xmlFile) throws MappingException {
try {
- File lazyfile = new File( xmlFile.getAbsolutePath() + ".bin" );
+ File cachedFile = new File( xmlFile.getAbsolutePath() + ".bin" );
org.dom4j.Document doc = null;
- List errors = new ArrayList();
final boolean useCachedFile = xmlFile.exists() &&
- lazyfile.exists() &&
- xmlFile.lastModified() < lazyfile.lastModified();
+ cachedFile.exists() &&
+ xmlFile.lastModified() < cachedFile.lastModified();
if ( useCachedFile ) {
try {
- log.info( "Reading mappings from cache file: " + lazyfile );
- doc = (org.dom4j.Document) SerializationHelper.deserialize( new FileInputStream( lazyfile ) );
+ log.info( "Reading mappings from cache file: " + cachedFile );
+ doc = ( org.dom4j.Document ) SerializationHelper.deserialize( new FileInputStream( cachedFile ) );
}
- catch (SerializationException e) {
- log.warn( "Could not deserialize cache file: " + lazyfile.getPath(), e );
+ catch ( SerializationException e ) {
+ log.warn( "Could not deserialize cache file: " + cachedFile.getPath(), e );
}
}
- // If deserialization failed or cached file does not exist
- if ( doc == null && xmlFile.exists()) {
+ // if doc is null, then for whatever reason, the cached file cannot be used...
+ if ( doc == null ) {
+ if ( !xmlFile.exists() ) {
+ throw new MappingNotFoundException( "file", xmlFile.toString() );
+ }
+
log.info( "Reading mappings from file: " + xmlFile );
- doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver )
- .read( xmlFile );
+ List errors = new ArrayList();
+ doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
+ }
+
try {
- log.debug( "Writing cache file for: " + xmlFile + " to: " + lazyfile );
- SerializationHelper.serialize( (Serializable) doc, new FileOutputStream( lazyfile ) );
+ log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
+ SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStream( cachedFile ) );
}
- catch (SerializationException e) {
- log.warn( "Could not write cached file: " + lazyfile, e );
+ catch ( SerializationException e ) {
+ log.warn( "Could not write cached file: " + cachedFile, e );
}
- } else {
- throw new MappingNotFoundException("file", xmlFile.toString());
}
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
- }
add( doc );
return this;
+
}
- catch (Exception e) {
- throw new InvalidMappingException("file", xmlFile.toString(), e);
+ catch ( MappingException e ) {
+ throw e;
}
+ catch ( Exception e ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), e );
+ }
}
+ /**
+ * Add a cacheable mapping file.
+ *
+ * @param xmlFile The name of the file to be added. This must be in a form
+ * useable to simply construct a {@link java.io.File} instance.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the cached file or processing
+ * the non-cached file.
+ * @see #addCacheableFile(java.io.File)
+ */
public Configuration addCacheableFile(String xmlFile) throws MappingException {
return addCacheableFile( new File( xmlFile ) );
}
18 years, 2 months
Hibernate SVN: r10708 - in branches/Branch_3_2/Hibernate3/test/org/hibernate/test: . cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 10:32:55 -0500 (Fri, 03 Nov 2006)
New Revision: 10708
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
Log:
HHH-2108 : fixed cacheable files
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml 2006-11-03 15:22:01 UTC (rev 10707)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml 2006-11-03 15:32:55 UTC (rev 10708)
@@ -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 entity-name="Entity">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="name" type="string" column="NAME"/>
+ </class>
+
+</hibernate-mapping>
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-11-03 15:22:01 UTC (rev 10707)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-11-03 15:32:55 UTC (rev 10708)
@@ -0,0 +1,41 @@
+package org.hibernate.test.cfg;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.hibernate.cfg.Configuration;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class CacheableFileTest extends TestCase {
+
+ public static final String MAPPING = "org/hibernate/test/cfg/Cacheable.hbm.xml";
+
+ private File mappingFile;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).getFile() );
+ assertTrue( mappingFile.exists() );
+ File cached = new File( mappingFile.getParentFile(), mappingFile.getName() + ".bin" );
+ if ( cached.exists() ) {
+ cached.delete();
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ mappingFile = null;
+ super.tearDown();
+ }
+
+ public void testCachedFiles() {
+ Configuration cfg = new Configuration();
+ cfg.addCacheableFile( mappingFile );
+ Configuration cfg2 = new Configuration();
+ cfg2.addCacheableFile( mappingFile );
+ }
+}
18 years, 2 months
Hibernate SVN: r10707 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/tool/hbm2x java/org/hibernate/tool/hbm2x/doc templates/doc templates/doc/entities templates/doc/tables test/org/hibernate/tool/hbm2x
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 10:22:01 -0500 (Fri, 03 Nov 2006)
New Revision: 10707
Added:
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/common.ftl
Removed:
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
Log:
HBX-807 Replace header frame with nicer javadoc-like nav
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/DocExporter.java 2006-11-03 15:22:01 UTC (rev 10707)
@@ -50,11 +50,6 @@
private static final String FILE_INDEX = "doc/index.html";
/**
- * The main header file.
- */
- private static final String FILE_HEADER = "doc/header.html";
-
- /**
* Template used for the index of the table documentation.
*/
private static final String FTL_TABLES_INDEX = "doc/tables/index.ftl";
@@ -306,10 +301,6 @@
DocFile mainIndexDocFile = docFileManager.getMainIndexDocFile();
DocFileManager.copy(FILE_INDEX, mainIndexDocFile.getFile() );
-
- DocFile headerFile = docFileManager.getHeaderDocFile();
-
- DocFileManager.copy(FILE_HEADER, headerFile.getFile() );
}
catch (IOException ioe) {
throw new RuntimeException("Error while copying files.", ioe);
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/doc/DocFileManager.java 2006-11-03 15:22:01 UTC (rev 10707)
@@ -32,11 +32,6 @@
private DocFile mainIndexDocFile;
/**
- * The header of the documentation.
- */
- private DocFile headerDocFile;
-
- /**
* Folder for the utility files.
*/
private DocFolder assetsDocFolder;
@@ -158,8 +153,6 @@
mainIndexDocFile = new DocFile("index.html", rootDocFolder);
- headerDocFile = new DocFile("header.html", rootDocFolder);
-
assetsDocFolder = new DocFolder("assets", rootDocFolder);
hibernateImageDocFile = new DocFile("hibernate_logo.gif",
@@ -270,16 +263,6 @@
}
/**
- * Returns the DocFile for the header.
- *
- * @return the value.
- */
- public DocFile getHeaderDocFile() {
-
- return headerDocFile;
- }
-
- /**
* Returns the DocFile for the Hibernate Image.
*
* @return the value.
Added: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/common.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/common.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/common.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -0,0 +1,35 @@
+<#macro header selected="">
+ <div id="header">
+
+ <div id="logo">
+ <a href="http://www.hibernate.org/" target="_blank">
+ <#assign src = docFileManager.getRef(docFile, docFileManager.getHibernateImageDocFile())>
+ <img src="${src}" alt="Hibernate"/>
+ </a>
+ </div>
+
+ <#-- unfortunately whitespace is significant here in browsers.. -->
+ <ul><#--
+ --><@headerItem id="tables" label="Tables" href=docFileManager.getRef(docFile, docFileManager.getTableIndexDocFile()) selected=selected/><#--
+ --><@headerItem id="entities" label="Entities" href=docFileManager.getRef(docFile, docFileManager.getClassIndexDocFile()) selected=selected/><#--
+ --></ul>
+
+ <hr/>
+
+ </div>
+</#macro>
+
+<#macro headerItem id label href selected>
+ <#-- unfortunately whitespace is significant here in browsers.. -->
+ <#if selected == id><#--
+ --><li class="selected"><#--
+ -->${label}<#--
+ --></li><#--
+ --><#else><#--
+ --><li><#--
+ --><a href="${href}" target="_top"><#--
+ -->${label}<#--
+ --></a><#--
+ --></li><#--
+ --></#if>
+</#macro>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/doc-style.css 2006-11-03 15:22:01 UTC (rev 10707)
@@ -4,6 +4,7 @@
body
{
+ margin: 0.5em;
background: white;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
@@ -28,6 +29,10 @@
{
margin: 0.5em 0;
}
+* html hr /* ie6 */
+{
+ margin: 0;
+}
h1
{
@@ -99,35 +104,55 @@
/* header */
-.HeaderBody
+#logo
{
- margin: 0;
- background: #F4F4F4;
+ float: right;
+ margin-bottom: 0.5em;
}
+* html #logo /* ie6 */
+{
+ margin-bottom: 0;
+}
-.HeaderTable
+#logo img
{
- width: 100%;
+ display: block;
+ border: none;
+}
+
+#header ul
+{
+ list-style: none;
+ background: #F4F4F4;
+ padding: 4px;
margin: 0;
- font-weight: bold;
- text-align: center;
}
-.HeaderTable th, .HeaderTable td
+#header li
{
- border: none;
+ display: inline;
+ margin-right: 3px;
+ padding: 0 3px;
}
-.HeaderTable img
+#header li.selected
{
- border: none;
+ background: silver;
+ color: white;
+ font-weight: bold;
}
-.HeaderLink
+#header a
{
- text-decoration: none;
+ color: black;
+ font-weight: bold;
}
+#header hr
+{
+ clear: right;
+}
+
/* entity hierarchy */
ul.EntityHierarchy
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,3 +1,5 @@
+<#import "/doc/common.ftl" as common>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -7,6 +9,8 @@
</head>
<body>
+ <@common.header/>
+
<h4>
<#if class.packageName?length gt 0>
${class.packageName}
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/package-summary.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,3 +1,5 @@
+<#import "/doc/common.ftl" as common>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -7,6 +9,8 @@
</head>
<body>
+ <@common.header/>
+
<h2>Package ${package}</h2>
<#if (classList.size() > 0)>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/summary.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,3 +1,5 @@
+<#import "/doc/common.ftl" as common>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -6,6 +8,8 @@
<link rel="stylesheet" type="text/css" href="${docFileManager.getRef(docFile, docFileManager.getCssStylesDocFile())}" title="Style"/>
</head>
<body>
+
+ <@common.header selected="entities"/>
<h1>Hibernate Mapping Documentation</h1>
Deleted: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/header.html 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,27 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html>
- <head>
- <title>Hibernate Mappings - Header</title>
- <link rel="stylesheet" type="text/css" href="assets/doc-style.css" title="Style"/>
- </head>
- <body class="HeaderBody">
-
- <table class="HeaderTable">
- <tr>
- <td style="width: 33%">
- <a class="HeaderLink" href="tables/index.html" target="mainFrame">TABLES</a>
- </td>
- <td style="width: 33%">
- <a class="HeaderLink" href="entities/index.html" target="mainFrame">ENTITIES</a>
- </td>
- <td style="width: 33%">
- <a href="http://www.hibernate.org/" target="_blank">
- <img src="assets/hibernate_logo.gif" alt="HIBERNATE"/>
- </a>
- </td>
- </tr>
- </table>
-
- </body>
-</html>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/index.html 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,20 +1,10 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Hibernate Mappings - Hibernate Mapping Information</title>
- <link rel="stylesheet" type="text/css" href="assets/doc-style.css" title="Style"/>
+ <meta http-equiv="refresh" content="0;url=entities/index.html"/>
</head>
-
- <frameset rows="50px,80%">
- <frame src="header.html" name="headerFrame" title="Header" scrolling="no"/>
- <frame src="entities/index.html" name="mainFrame" title="Main"/>
- <noframes>
- <body>
- <h2>Frame Alert</h2>
- <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.</p>
- </body>
- </noframes>
- </frameset>
-
+ <body>
+ </body>
</html>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/schema-summary.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,3 +1,5 @@
+<#import "/doc/common.ftl" as common>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -7,6 +9,8 @@
</head>
<body>
+ <@common.header/>
+
<h2>Schema ${schema}</h2>
<table>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/summary.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,3 +1,5 @@
+<#import "/doc/common.ftl" as common>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -7,6 +9,8 @@
</head>
<body>
+ <@common.header selected="tables"/>
+
<h1>Hibernate Mapping Documentation</h1>
<#if graphsGenerated>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/tables/table.ftl 2006-11-03 15:22:01 UTC (rev 10707)
@@ -1,3 +1,5 @@
+<#import "/doc/common.ftl" as common>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -7,6 +9,8 @@
</head>
<body>
+ <@common.header/>
+
<h4>Schema ${dochelper.getQualifiedSchemaName(table)}</h4>
<h2>Table ${table.name}</h2>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-11-03 14:05:56 UTC (rev 10706)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-11-03 15:22:01 UTC (rev 10707)
@@ -45,7 +45,6 @@
}
public void testExporter() {
- assertFileAndExists(new File(getOutputDir(), "header.html") );
assertFileAndExists(new File(getOutputDir(), "index.html") );
assertFileAndExists(new File(getOutputDir(), "assets/doc-style.css") );
@@ -54,7 +53,7 @@
assertFileAndExists(new File(getOutputDir(), "tables/PUBLIC/summary.html") );
assertFileAndExists(new File(getOutputDir(), "tables/PUBLIC/Customer.html") );
assertFalse(new File(getOutputDir(), "tables/PUBLIC/UPerson.html").exists() );
- assertFileAndExists(new File(getOutputDir(), "tables/PUBLIC/CROWN_USERS.html") );
+ assertFileAndExists(new File(getOutputDir(), "tables/CROWN/CROWN_USERS.html") );
assertFileAndExists(new File(getOutputDir(), "entities/org/hibernate/tool/hbm2x/Customer.html") );
assertTrue(new File(getOutputDir(), "entities/org/hibernate/tool/hbm2x/UPerson.html").exists() );
18 years, 2 months
Hibernate SVN: r10706 - in branches/Branch_3_2/Hibernate3: src/org/hibernate/cfg src/org/hibernate/tool/hbm2ddl test/org/hibernate/test test/org/hibernate/test/tool
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 09:05:56 -0500 (Fri, 03 Nov 2006)
New Revision: 10706
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.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 SchemaUpdate/validator doesn't listen to quoting
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-03 13:38:40 UTC (rev 10705)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 14:05:56 UTC (rev 10706)
@@ -879,7 +879,8 @@
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
( table.getSchema() == null ) ? settings.getDefaultSchemaName() : table.getSchema(),
- ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog()
+ ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog(),
+ table.isQuoted()
);
if ( tableInfo == null ) {
@@ -921,7 +922,8 @@
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
table.getSchema(),
- table.getCatalog()
+ table.getCatalog(),
+ table.isQuoted()
);
if ( dialect.hasAlterTable() ) {
@@ -1000,7 +1002,8 @@
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
( table.getSchema() == null ) ? settings.getDefaultSchemaName() : table.getSchema(),
- ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog());
+ ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog(),
+ table.isQuoted());
if ( tableInfo == null ) {
throw new HibernateException( "Missing table: " + table.getName() );
}
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-03 13:38:40 UTC (rev 10705)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-03 14:05:56 UTC (rev 10706)
@@ -48,7 +48,7 @@
private static final String[] TYPES = {"TABLE"};
- public TableMetadata getTableMetadata(String name, String schema, String catalog) throws HibernateException {
+ public TableMetadata getTableMetadata(String name, String schema, String catalog, boolean isQuoted) throws HibernateException {
Object identifier = identifier(catalog, schema, name);
TableMetadata table = (TableMetadata) tables.get(identifier);
@@ -61,7 +61,8 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
+ if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
+ || (!isQuoted && meta.storesUpperCaseIdentifiers() )) {
rs = meta.getTables(
StringHelper.toUpperCase(catalog),
StringHelper.toUpperCase(schema),
@@ -69,7 +70,8 @@
TYPES
);
}
- else if ( meta.storesLowerCaseIdentifiers() ) {
+ else if ( (isQuoted && meta.storesLowerCaseQuotedIdentifiers())
+ || (!isQuoted && meta.storesLowerCaseIdentifiers() )) {
rs = meta.getTables(
StringHelper.toLowerCase(catalog),
StringHelper.toLowerCase(schema),
@@ -140,27 +142,33 @@
public boolean isSequence(Object key) {
if (key instanceof String){
String[] strings = StringHelper.split(".", (String) key);
- return sequences.contains( ( (String) strings[strings.length-1] ).toLowerCase());
+ return sequences.contains( strings[strings.length-1].toLowerCase());
}
return false;
}
- public boolean isTable(Object key) throws HibernateException {
- if(key instanceof String) {
- if ( getTableMetadata( (String) key, null, null ) != null ) {
- return true;
- } else {
- String[] strings = StringHelper.split(".", (String) key);
- if(strings.length==3) {
- return getTableMetadata(strings[2], strings[1], strings[0]) != null;
- } else if (strings.length==2) {
- return getTableMetadata(strings[1], strings[0], null) != null;
- }
- }
- }
- return false;
- }
-
+ public boolean isTable(Object key) throws HibernateException {
+ if(key instanceof String) {
+ Table tbl = new Table((String)key);
+ if ( getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null ) {
+ return true;
+ } else {
+ String[] strings = StringHelper.split(".", (String) key);
+ if(strings.length==3) {
+ tbl = new Table(strings[2]);
+ tbl.setCatalog(strings[0]);
+ tbl.setSchema(strings[1]);
+ return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
+ } else if (strings.length==2) {
+ tbl = new Table(strings[1]);
+ tbl.setSchema(strings[0]);
+ return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
+ }
+ }
+ }
+ return false;
+ }
+
public String toString() {
return "DatabaseMetadata" + tables.keySet().toString() + sequences.toString();
}
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-03 13:38:40 UTC (rev 10705)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-03 14:05:56 UTC (rev 10706)
@@ -9,11 +9,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.util.StringHelper;
/**
* JDBC table metadata
- * @author Christoph Sturm
+ * @author Christoph Sturm, Max Rydahl Andersen
*/
public class TableMetadata {
@@ -108,24 +107,7 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
- rs = meta.getImportedKeys(
- StringHelper.toUpperCase(catalog),
- StringHelper.toUpperCase(schema),
- StringHelper.toUpperCase(name)
- );
- }
- else if ( meta.storesLowerCaseIdentifiers() ) {
- rs = meta.getImportedKeys(
- StringHelper.toLowerCase(catalog),
- StringHelper.toLowerCase(schema),
- StringHelper.toLowerCase(name)
- );
- }
- else {
- rs = meta.getImportedKeys(catalog, schema, name);
- }
-
+ rs = meta.getImportedKeys(catalog, schema, name);
while ( rs.next() ) addForeignKey(rs);
}
finally {
@@ -137,28 +119,8 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
- rs = meta.getIndexInfo(
- StringHelper.toUpperCase(catalog),
- StringHelper.toUpperCase(schema),
- StringHelper.toUpperCase(name),
- false,
- true
- );
- }
- else if ( meta.storesLowerCaseIdentifiers() ) {
- rs = meta.getIndexInfo(
- StringHelper.toLowerCase(catalog),
- StringHelper.toLowerCase(schema),
- StringHelper.toLowerCase(name),
- false,
- true
- );
- }
- else {
- rs = meta.getIndexInfo(catalog, schema, name, false, true);
- }
-
+ rs = meta.getIndexInfo(catalog, schema, name, false, true);
+
while ( rs.next() ) {
if ( rs.getShort("TYPE") == DatabaseMetaData.tableIndexStatistic ) continue;
addIndex(rs);
@@ -173,26 +135,7 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
- rs = meta.getColumns(
- StringHelper.toUpperCase(catalog),
- StringHelper.toUpperCase(schema),
- StringHelper.toUpperCase(name),
- "%"
- );
- }
- else if ( meta.storesLowerCaseIdentifiers() ) {
- rs = meta.getColumns(
- StringHelper.toLowerCase(catalog),
- StringHelper.toLowerCase(schema),
- StringHelper.toLowerCase(name),
- "%"
- );
- }
- else {
- rs = meta.getColumns(catalog, schema, name, "%");
- }
-
+ rs = meta.getColumns(catalog, schema, name, "%");
while ( rs.next() ) addColumn(rs);
}
finally {
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml 2006-11-03 13:38:40 UTC (rev 10705)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml 2006-11-03 14:05:56 UTC (rev 10706)
@@ -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: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.java 2006-11-03 13:38:40 UTC (rev 10705)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/Team.java 2006-11-03 14:05:56 UTC (rev 10706)
@@ -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: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-11-03 13:38:40 UTC (rev 10705)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-11-03 14:05:56 UTC (rev 10706)
@@ -0,0 +1,209 @@
+package org.hibernate.test.tool;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.test.TestCase;
+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 TestCase{
+
+ 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();
+ }
+
+ public TestSchemaTools(String arg0) {
+ super(arg0);
+ }
+
+ public String[] getMappings() {
+ return new String[] {"tool/Team.hbm.xml"};
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestSchemaTools.class);
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestRunner.run( suite() );
+ }
+
+ protected boolean recreateSchema() {
+ return false;
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.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();
+ conn.close();
+
+ }
+
+
+
+}
18 years, 2 months
Hibernate SVN: r10705 - branches/Branch_3_2/Hibernate3/doc/reference/en/modules
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 08:38:40 -0500 (Fri, 03 Nov 2006)
New Revision: 10705
Modified:
branches/Branch_3_2/Hibernate3/doc/reference/en/modules/filters.xml
Log:
HHH-2127 : document default filter conditions
Modified: branches/Branch_3_2/Hibernate3/doc/reference/en/modules/filters.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/doc/reference/en/modules/filters.xml 2006-11-03 13:38:30 UTC (rev 10704)
+++ branches/Branch_3_2/Hibernate3/doc/reference/en/modules/filters.xml 2006-11-03 13:38:40 UTC (rev 10705)
@@ -7,7 +7,7 @@
enabled or disabled for a particular Hibernate session.
</para>
- <sect1 id="objectstate-filters">
+ <sect1 id="objectstate-filters" revision="1">
<title>Hibernate filters</title>
<para>
@@ -123,6 +123,23 @@
the operator.
</para>
+ <para>
+ After being defined a filter might be attached to multiple entities and/or
+ collections each with its own condition. That can be tedious when the
+ conditions are the same each time. Thus <literal><filter-def/></literal>
+ allows defining a default condition, either as an attribute or CDATA:
+ </para>
+
+ <programlisting><![CDATA[<filter-def name="myFilter" condition="abc > xyz">...</filter-def>
+<filter-def name="myOtherFilter">abc=xyz</filter-def>]]></programlisting>
+
+ <para>
+ This default condition will then be used whenever the filter is attached to something
+ without specifying a condition. Note that this means you can give a specific condition
+ as part of the attachment of the filter which overrides the default condition in that
+ particular case.
+ </para>
+
</sect1>
</chapter>
18 years, 2 months
Hibernate SVN: r10704 - trunk/Hibernate3/doc/reference/en/modules
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 08:38:30 -0500 (Fri, 03 Nov 2006)
New Revision: 10704
Modified:
trunk/Hibernate3/doc/reference/en/modules/filters.xml
Log:
HHH-2127 : document default filter conditions
Modified: trunk/Hibernate3/doc/reference/en/modules/filters.xml
===================================================================
--- trunk/Hibernate3/doc/reference/en/modules/filters.xml 2006-11-03 13:22:57 UTC (rev 10703)
+++ trunk/Hibernate3/doc/reference/en/modules/filters.xml 2006-11-03 13:38:30 UTC (rev 10704)
@@ -7,7 +7,7 @@
enabled or disabled for a particular Hibernate session.
</para>
- <sect1 id="objectstate-filters">
+ <sect1 id="objectstate-filters" revision="1">
<title>Hibernate filters</title>
<para>
@@ -123,6 +123,23 @@
the operator.
</para>
+ <para>
+ After being defined a filter might be attached to multiple entities and/or
+ collections each with its own condition. That can be tedious when the
+ conditions are the same each time. Thus <literal><filter-def/></literal>
+ allows defining a default condition, either as an attribute or CDATA:
+ </para>
+
+ <programlisting><![CDATA[<filter-def name="myFilter" condition="abc > xyz">...</filter-def>
+<filter-def name="myOtherFilter">abc=xyz</filter-def>]]></programlisting>
+
+ <para>
+ This default condition will then be used whenever the filter is attached to something
+ without specifying a condition. Note that this means you can give a specific condition
+ as part of the attachment of the filter which overrides the default condition in that
+ particular case.
+ </para>
+
</sect1>
</chapter>
18 years, 2 months
Hibernate SVN: r10703 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 08:22:57 -0500 (Fri, 03 Nov 2006)
New Revision: 10703
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
Log:
use db metadata to decide proper casing (also for quotes)
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java 2006-11-03 13:19:20 UTC (rev 10702)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java 2006-11-03 13:22:57 UTC (rev 10703)
@@ -145,11 +145,17 @@
protected String caseForSearch(String value) throws SQLException {
// TODO: handle quoted requests (just strip it ?)
if(needQuote(value)) {
- return value;
+ if ( getMetaData().storesUpperCaseQuotedIdentifiers() ) {
+ return StringHelper.toUpperCase( value );
+ } else if( getMetaData().storesLowerCaseQuotedIdentifiers() ) {
+ return StringHelper.toLowerCase( value );
+ } else {
+ return value;
+ }
}
if ( getMetaData().storesUpperCaseIdentifiers() ) {
return StringHelper.toUpperCase( value );
- } else if( getMetaData().storesUpperCaseIdentifiers() ) {
+ } else if( getMetaData().storesLowerCaseIdentifiers() ) {
return StringHelper.toLowerCase( value );
} else {
return value;
18 years, 2 months
Hibernate SVN: r10702 - in branches/Branch_3_2/Hibernate3/src/org/hibernate: cfg tool/hbm2ddl
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 08:19:20 -0500 (Fri, 03 Nov 2006)
New Revision: 10702
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
Log:
HHH-2208 Table schema use in DatabaseMetadata
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-03 12:20:54 UTC (rev 10701)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 13:19:20 UTC (rev 10702)
@@ -875,11 +875,12 @@
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
-
+ Settings settings = buildSettings();
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
- table.getSchema(),
- table.getCatalog()
+ ( table.getSchema() == null ) ? settings.getDefaultSchemaName() : table.getSchema(),
+ ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog()
+
);
if ( tableInfo == null ) {
script.add(
@@ -994,13 +995,12 @@
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
+ Settings settings = buildSettings();
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
- table.getSchema(),
- table.getCatalog()
- );
-
+ ( table.getSchema() == null ) ? settings.getDefaultSchemaName() : table.getSchema(),
+ ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog());
if ( tableInfo == null ) {
throw new HibernateException( "Missing table: " + table.getName() );
}
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-03 12:20:54 UTC (rev 10701)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-03 13:19:20 UTC (rev 10702)
@@ -16,6 +16,7 @@
import org.hibernate.HibernateException;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.mapping.Table;
import org.hibernate.dialect.Dialect;
import org.hibernate.util.StringHelper;
@@ -49,7 +50,8 @@
public TableMetadata getTableMetadata(String name, String schema, String catalog) throws HibernateException {
- TableMetadata table = (TableMetadata) tables.get(name);
+ Object identifier = identifier(catalog, schema, name);
+ TableMetadata table = (TableMetadata) tables.get(identifier);
if (table!=null) {
return table;
}
@@ -83,7 +85,7 @@
String tableName = rs.getString("TABLE_NAME");
if ( name.equalsIgnoreCase(tableName) ) {
table = new TableMetadata(rs, meta, extras);
- tables.put(name, table);
+ tables.put(identifier, table);
return table;
}
}
@@ -107,6 +109,10 @@
}
+ private Object identifier(String catalog, String schema, String name) {
+ return Table.qualify(catalog,schema,name);
+ }
+
private void initSequences(Connection connection, Dialect dialect) throws SQLException {
if ( dialect.supportsSequences() ) {
String sql = dialect.getQuerySequencesString();
@@ -132,7 +138,11 @@
}
public boolean isSequence(Object key) {
- return key instanceof String && sequences.contains( ( (String) key ).toLowerCase() );
+ if (key instanceof String){
+ String[] strings = StringHelper.split(".", (String) key);
+ return sequences.contains( ( (String) strings[strings.length-1] ).toLowerCase());
+ }
+ return false;
}
public boolean isTable(Object key) throws HibernateException {
18 years, 2 months