Hibernate SVN: r16654 - in core/branches/Branch_3_3/core/src: main/java/org/hibernate/loader and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 17:11:43 -0400 (Mon, 01 Jun 2009)
New Revision: 16654
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/cache/QueryKey.java
core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/Loader.java
core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/CollectionHelper.java
core/branches/Branch_3_3/core/src/test/java/org/hibernate/cache/QueryKeyTest.java
Log:
HHH-3383 - QueryKey is storing references to entities instead of identifiers
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cache/QueryKey.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/cache/QueryKey.java 2009-06-01 20:36:35 UTC (rev 16653)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/cache/QueryKey.java 2009-06-01 21:11:43 UTC (rev 16654)
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.cache;
@@ -28,29 +27,37 @@
import java.io.IOException;
import java.util.Map;
import java.util.Set;
+import java.util.Iterator;
import org.hibernate.EntityMode;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.RowSelection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.TypedValue;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.Type;
import org.hibernate.util.EqualsHelper;
+import org.hibernate.util.CollectionHelper;
/**
- * A key that identifies a particular query with bound parameter values
+ * A key that identifies a particular query with bound parameter values. This is the object Hibernate uses
+ * as its key into its query cache.
+ *
* @author Gavin King
+ * @author Steve Ebersole
*/
public class QueryKey implements Serializable {
private final String sqlQueryString;
- private final Type[] types;
- private final Object[] values;
+ private final Type[] positionalParameterTypes;
+ private final Object[] positionalParameterValues;
+ private final Map namedParameters;
private final Integer firstRow;
private final Integer maxRows;
- private final Map namedParameters;
private final EntityMode entityMode;
- private final Set filters;
-
- // the user provided resulttransformer, not the one used with "select new". Here to avoid mangling transformed/non-transformed results.
+ private final Set filterKeys;
+
+ // the user provided resulttransformer, not the one used with "select new". Here to avoid mangling
+ // transformed/non-transformed results.
private final ResultTransformer customTransformer;
/**
@@ -58,13 +65,52 @@
* recalculated as part of the serialization process which allows distributed query caches to work properly.
*/
private transient int hashCode;
-
- public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
- this.sqlQueryString = queryString;
- this.types = queryParameters.getPositionalParameterTypes();
- this.values = queryParameters.getPositionalParameterValues();
- RowSelection selection = queryParameters.getRowSelection();
- if (selection!=null) {
+
+ /**
+ * Generates a QueryKey.
+ *
+ * @param queryString The sql query string.
+ * @param queryParameters The query parameters
+ * @param filterKeys The keys of any enabled filters.
+ * @param session The current session.
+ *
+ * @return The generate query cache key.
+ */
+ public static QueryKey generateQueryKey(
+ String queryString,
+ QueryParameters queryParameters,
+ Set filterKeys,
+ SessionImplementor session) {
+ // disassemble positional parameters
+ final int positionalParameterCount = queryParameters.getPositionalParameterTypes().length;
+ final Type[] types = new Type[positionalParameterCount];
+ final Object[] values = new Object[positionalParameterCount];
+ for ( int i = 0; i < positionalParameterCount; i++ ) {
+ types[i] = queryParameters.getPositionalParameterTypes()[i];
+ values[i] = types[i].disassemble( queryParameters.getPositionalParameterValues()[i], session, null );
+ }
+
+ // disassemble named parameters
+ Map namedParameters = CollectionHelper.mapOfSize( queryParameters.getNamedParameters().size() );
+ Iterator itr = queryParameters.getNamedParameters().entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final Map.Entry namedParameterEntry = ( Map.Entry ) itr.next();
+ final TypedValue original = ( TypedValue ) namedParameterEntry.getValue();
+ namedParameters.put(
+ namedParameterEntry.getKey(),
+ new TypedValue(
+ original.getType(),
+ original.getType().disassemble( original.getValue(), session, null ),
+ session.getEntityMode()
+ )
+ );
+ }
+
+ // decode row selection...
+ final RowSelection selection = queryParameters.getRowSelection();
+ final Integer firstRow;
+ final Integer maxRows;
+ if ( selection != null ) {
firstRow = selection.getFirstRow();
maxRows = selection.getMaxRows();
}
@@ -72,13 +118,63 @@
firstRow = null;
maxRows = null;
}
- this.namedParameters = queryParameters.getNamedParameters();
+
+ return new QueryKey(
+ queryString,
+ types,
+ values,
+ namedParameters,
+ firstRow,
+ maxRows,
+ filterKeys,
+ session.getEntityMode(),
+ queryParameters.getResultTransformer()
+ );
+ }
+
+ /**
+ * Package-protected constructor.
+ *
+ * @param sqlQueryString The sql query string.
+ * @param positionalParameterTypes Positional parameter types.
+ * @param positionalParameterValues Positional parameter values.
+ * @param namedParameters Named parameters.
+ * @param firstRow First row selection, if any.
+ * @param maxRows Max-rows selection, if any.
+ * @param filterKeys Enabled filter keys, if any.
+ * @param entityMode The entity mode.
+ * @param customTransformer Custom result transformer, if one.
+ */
+ QueryKey(
+ String sqlQueryString,
+ Type[] positionalParameterTypes,
+ Object[] positionalParameterValues,
+ Map namedParameters,
+ Integer firstRow,
+ Integer maxRows,
+ Set filterKeys,
+ EntityMode entityMode,
+ ResultTransformer customTransformer) {
+ this.sqlQueryString = sqlQueryString;
+ this.positionalParameterTypes = positionalParameterTypes;
+ this.positionalParameterValues = positionalParameterValues;
+ this.namedParameters = namedParameters;
+ this.firstRow = firstRow;
+ this.maxRows = maxRows;
this.entityMode = entityMode;
- this.filters = filters;
- this.customTransformer = queryParameters.getResultTransformer();
+ this.filterKeys = filterKeys;
+ this.customTransformer = customTransformer;
this.hashCode = generateHashCode();
}
+ /**
+ * Deserialization hook used to re-init the cached hashcode which is needed for proper clustering support.
+ *
+ * @param in The object input stream.
+ *
+ * @throws IOException Thrown by normal deserialization
+ * @throws ClassNotFoundException Thrown by normal deserialization
+ */
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
this.hashCode = generateHashCode();
@@ -88,65 +184,95 @@
int result = 13;
result = 37 * result + ( firstRow==null ? 0 : firstRow.hashCode() );
result = 37 * result + ( maxRows==null ? 0 : maxRows.hashCode() );
- for ( int i=0; i<values.length; i++ ) {
- result = 37 * result + ( values[i]==null ? 0 : types[i].getHashCode( values[i], entityMode ) );
+ for ( int i=0; i< positionalParameterValues.length; i++ ) {
+ result = 37 * result + ( positionalParameterValues[i]==null ? 0 : positionalParameterTypes[i].getHashCode( positionalParameterValues[i], entityMode ) );
}
result = 37 * result + ( namedParameters==null ? 0 : namedParameters.hashCode() );
- result = 37 * result + ( filters==null ? 0 : filters.hashCode() );
+ result = 37 * result + ( filterKeys ==null ? 0 : filterKeys.hashCode() );
result = 37 * result + ( customTransformer==null ? 0 : customTransformer.hashCode() );
result = 37 * result + sqlQueryString.hashCode();
return result;
}
- public int hashCode() {
- return hashCode;
- }
-
+ /**
+ * {@inheritDoc}
+ */
public boolean equals(Object other) {
- if (!(other instanceof QueryKey)) return false;
- QueryKey that = (QueryKey) other;
- if ( !sqlQueryString.equals(that.sqlQueryString) ) return false;
- if ( !EqualsHelper.equals(firstRow, that.firstRow) || !EqualsHelper.equals(maxRows, that.maxRows) ) return false;
- if ( !EqualsHelper.equals(customTransformer, that.customTransformer) ) return false;
- if (types==null) {
- if (that.types!=null) return false;
+ if ( !( other instanceof QueryKey ) ) {
+ return false;
}
+ QueryKey that = ( QueryKey ) other;
+ if ( !sqlQueryString.equals( that.sqlQueryString ) ) {
+ return false;
+ }
+ if ( !EqualsHelper.equals( firstRow, that.firstRow ) || !EqualsHelper.equals( maxRows, that.maxRows ) ) {
+ return false;
+ }
+ if ( !EqualsHelper.equals( customTransformer, that.customTransformer ) ) {
+ return false;
+ }
+ if ( positionalParameterTypes == null ) {
+ if ( that.positionalParameterTypes != null ) {
+ return false;
+ }
+ }
else {
- if (that.types==null) return false;
- if ( types.length!=that.types.length ) return false;
- for ( int i=0; i<types.length; i++ ) {
- if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) return false;
- if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) return false;
+ if ( that.positionalParameterTypes == null ) {
+ return false;
}
+ if ( positionalParameterTypes.length != that.positionalParameterTypes.length ) {
+ return false;
+ }
+ for ( int i = 0; i < positionalParameterTypes.length; i++ ) {
+ if ( positionalParameterTypes[i].getReturnedClass() != that.positionalParameterTypes[i].getReturnedClass() ) {
+ return false;
+ }
+ if ( !positionalParameterTypes[i].isEqual( positionalParameterValues[i], that.positionalParameterValues[i], entityMode ) ) {
+ return false;
+ }
+ }
}
- if ( !EqualsHelper.equals(filters, that.filters) ) return false;
- if ( !EqualsHelper.equals(namedParameters, that.namedParameters) ) return false;
- return true;
+
+ return EqualsHelper.equals( filterKeys, that.filterKeys )
+ && EqualsHelper.equals( namedParameters, that.namedParameters );
}
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode() {
+ return hashCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String toString() {
StringBuffer buf = new StringBuffer()
- .append("sql: ")
- .append(sqlQueryString);
- if (values!=null) {
- buf.append("; parameters: ");
- for (int i=0; i<values.length; i++) {
- buf.append( values[i] )
- .append(", ");
+ .append( "sql: " )
+ .append( sqlQueryString );
+ if ( positionalParameterValues != null ) {
+ buf.append( "; parameters: " );
+ for ( int i = 0; i < positionalParameterValues.length; i++ ) {
+ buf.append( positionalParameterValues[i] ).append( ", " );
}
}
- if (namedParameters!=null) {
- buf.append("; named parameters: ")
- .append(namedParameters);
+ if ( namedParameters != null ) {
+ buf.append( "; named parameters: " ).append( namedParameters );
}
- if (filters!=null) {
- buf.append("; filters: ")
- .append(filters);
+ if ( filterKeys != null ) {
+ buf.append( "; filterKeys: " ).append( filterKeys );
}
- if (firstRow!=null) buf.append("; first row: ").append(firstRow);
- if (maxRows!=null) buf.append("; max rows: ").append(maxRows);
- if (customTransformer!=null) buf.append("; transformer: ").append(customTransformer);
+ if ( firstRow != null ) {
+ buf.append( "; first row: " ).append( firstRow );
+ }
+ if ( maxRows != null ) {
+ buf.append( "; max rows: " ).append( maxRows );
+ }
+ if ( customTransformer != null ) {
+ buf.append( "; transformer: " ).append( customTransformer );
+ }
return buf.toString();
}
-
+
}
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/Loader.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/Loader.java 2009-06-01 20:36:35 UTC (rev 16653)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/Loader.java 2009-06-01 21:11:43 UTC (rev 16654)
@@ -2138,15 +2138,15 @@
QueryCache queryCache = factory.getQueryCache( queryParameters.getCacheRegion() );
Set filterKeys = FilterKey.createFilterKeys(
- session.getEnabledFilters(),
+ session.getEnabledFilters(),
session.getEntityMode()
- );
- QueryKey key = new QueryKey(
+ );
+ QueryKey key = QueryKey.generateQueryKey(
getSQLString(),
queryParameters,
filterKeys,
- session.getEntityMode()
- );
+ session
+ );
List result = getResultFromQueryCache(
session,
@@ -2155,7 +2155,7 @@
resultTypes,
queryCache,
key
- );
+ );
if ( result == null ) {
result = doList( session, queryParameters );
@@ -2167,7 +2167,7 @@
queryCache,
key,
result
- );
+ );
}
return getResultList( result, queryParameters.getResultTransformer() );
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/CollectionHelper.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/CollectionHelper.java 2009-06-01 20:36:35 UTC (rev 16653)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/util/CollectionHelper.java 2009-06-01 21:11:43 UTC (rev 16654)
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.util;
@@ -32,7 +31,10 @@
import java.util.Map;
/**
+ * Various help for handling collections.
+ *
* @author Gavin King
+ * @author Steve Ebersole
*/
public final class CollectionHelper {
@@ -40,6 +42,19 @@
public static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList(0) );
public static final Map EMPTY_MAP = Collections.unmodifiableMap( new HashMap(0) );
- private CollectionHelper() {}
+ private CollectionHelper() {
+ }
+ /**
+ * Build a properly sized map, especially handling load size and load factor to prevent immediate resizing.
+ * <p/>
+ * Especially helpful for copy map contents.
+ *
+ * @param size The size to make the map.
+ * @return The sized map.
+ */
+ public static Map mapOfSize(int size) {
+ final int currentSize = (int) (size / 0.75f);
+ return new HashMap( Math.max( currentSize+ 1, 16), 0.75f );
+ }
}
Modified: core/branches/Branch_3_3/core/src/test/java/org/hibernate/cache/QueryKeyTest.java
===================================================================
--- core/branches/Branch_3_3/core/src/test/java/org/hibernate/cache/QueryKeyTest.java 2009-06-01 20:36:35 UTC (rev 16653)
+++ core/branches/Branch_3_3/core/src/test/java/org/hibernate/cache/QueryKeyTest.java 2009-06-01 21:11:43 UTC (rev 16654)
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.cache;
@@ -29,7 +28,6 @@
import junit.framework.TestCase;
-import org.hibernate.engine.QueryParameters;
import org.hibernate.EntityMode;
import org.hibernate.transform.RootEntityResultTransformer;
import org.hibernate.transform.ResultTransformer;
@@ -49,35 +47,31 @@
private static final String QUERY_STRING = "the query string";
public void testSerializedEquality() {
- doTest( buildBasicKey( new QueryParameters() ) );
+ doTest( buildBasicKey( null ) );
}
public void testSerializedEqualityWithResultTransformer() {
- doTest( buildBasicKey( buildQueryParameters( RootEntityResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( DistinctRootEntityResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( DistinctResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( AliasToEntityMapResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( PassThroughResultTransformer.INSTANCE ) ) );
+ doTest( buildBasicKey( RootEntityResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( DistinctRootEntityResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( DistinctResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( AliasToEntityMapResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( PassThroughResultTransformer.INSTANCE ) );
}
- private QueryParameters buildQueryParameters(ResultTransformer resultTransformer) {
- return new QueryParameters(
- ArrayHelper.EMPTY_TYPE_ARRAY, // param types
- ArrayHelper.EMPTY_OBJECT_ARRAY, // param values
- Collections.EMPTY_MAP, // lock modes
- null, // row selection
- false, // cacheable?
- "", // cache region
- "", // SQL comment
- false, // is natural key lookup?
- resultTransformer // the result transformer, duh! ;)
+ private QueryKey buildBasicKey(ResultTransformer resultTransformer) {
+ return new QueryKey(
+ QUERY_STRING,
+ ArrayHelper.EMPTY_TYPE_ARRAY, // positional param types
+ ArrayHelper.EMPTY_OBJECT_ARRAY, // positional param values
+ Collections.EMPTY_MAP, // named params
+ null, // firstRow selection
+ null, // maxRows selection
+ Collections.EMPTY_SET, // filter keys
+ EntityMode.POJO, // entity mode
+ resultTransformer // the result transformer
);
}
- private QueryKey buildBasicKey(QueryParameters queryParameters) {
- return new QueryKey( QUERY_STRING, queryParameters, Collections.EMPTY_SET, EntityMode.POJO );
- }
-
private void doTest(QueryKey key) {
HashMap map = new HashMap();
15 years, 7 months
Hibernate SVN: r16653 - in core/branches/Branch_3_2/src/org/hibernate: loader and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 16:36:35 -0400 (Mon, 01 Jun 2009)
New Revision: 16653
Modified:
core/branches/Branch_3_2/src/org/hibernate/cache/QueryKey.java
core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java
core/branches/Branch_3_2/src/org/hibernate/util/CollectionHelper.java
Log:
HHH-3383 - QueryKey is storing references to entities instead of identifiers
Modified: core/branches/Branch_3_2/src/org/hibernate/cache/QueryKey.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/cache/QueryKey.java 2009-06-01 18:54:44 UTC (rev 16652)
+++ core/branches/Branch_3_2/src/org/hibernate/cache/QueryKey.java 2009-06-01 20:36:35 UTC (rev 16653)
@@ -1,19 +1,47 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache;
import java.io.Serializable;
+import java.io.IOException;
import java.util.Map;
import java.util.Set;
+import java.util.Iterator;
import org.hibernate.EntityMode;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.RowSelection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.TypedValue;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.Type;
import org.hibernate.util.EqualsHelper;
+import org.hibernate.util.CollectionHelper;
/**
* A key that identifies a particular query with bound parameter values
+ *
* @author Gavin King
*/
public class QueryKey implements Serializable {
@@ -25,17 +53,51 @@
private final Map namedParameters;
private final EntityMode entityMode;
private final Set filters;
- private final int hashCode;
-
+
// the user provided resulttransformer, not the one used with "select new". Here to avoid mangling transformed/non-transformed results.
private final ResultTransformer customTransformer;
-
- public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
- this.sqlQueryString = queryString;
- this.types = queryParameters.getPositionalParameterTypes();
- this.values = queryParameters.getPositionalParameterValues();
- RowSelection selection = queryParameters.getRowSelection();
- if (selection!=null) {
+
+ /**
+ * For performance reasons, the hashCode is cached; however, it is marked transient so that it can be
+ * recalculated as part of the serialization process which allows distributed query caches to work properly.
+ */
+ private transient int hashCode;
+
+ public static QueryKey generateQueryKey(
+ String queryString,
+ QueryParameters queryParameters,
+ Set filters,
+ SessionImplementor session) {
+ // disassemble positional parameters
+ final int positionalParameterCount = queryParameters.getPositionalParameterTypes().length;
+ final Type[] types = new Type[positionalParameterCount];
+ final Object[] values = new Object[positionalParameterCount];
+ for ( int i = 0; i < positionalParameterCount; i++ ) {
+ types[i] = queryParameters.getPositionalParameterTypes()[i];
+ values[i] = types[i].disassemble( queryParameters.getPositionalParameterValues()[i], session, null );
+ }
+
+ // disassemble named parameters
+ Map namedParameters = CollectionHelper.mapOfSize( queryParameters.getNamedParameters().size() );
+ Iterator itr = queryParameters.getNamedParameters().entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final Map.Entry namedParameterEntry = ( Map.Entry ) itr.next();
+ final TypedValue original = ( TypedValue ) namedParameterEntry.getValue();
+ namedParameters.put(
+ namedParameterEntry.getKey(),
+ new TypedValue(
+ original.getType(),
+ original.getType().disassemble( original.getValue(), session, null ),
+ session.getEntityMode()
+ )
+ );
+ }
+
+ // decode row selection...
+ final RowSelection selection = queryParameters.getRowSelection();
+ final Integer firstRow;
+ final Integer maxRows;
+ if ( selection != null ) {
firstRow = selection.getFirstRow();
maxRows = selection.getMaxRows();
}
@@ -43,40 +105,48 @@
firstRow = null;
maxRows = null;
}
- this.namedParameters = queryParameters.getNamedParameters();
+
+ return new QueryKey(
+ queryString,
+ types,
+ values,
+ namedParameters,
+ firstRow,
+ maxRows,
+ filters,
+ session.getEntityMode(),
+ queryParameters.getResultTransformer()
+ );
+ }
+
+ /*package*/ QueryKey(
+ String sqlQueryString,
+ Type[] types,
+ Object[] values,
+ Map namedParameters,
+ Integer firstRow,
+ Integer maxRows,
+ Set filters,
+ EntityMode entityMode,
+ ResultTransformer customTransformer) {
+ this.sqlQueryString = sqlQueryString;
+ this.types = types;
+ this.values = values;
+ this.namedParameters = namedParameters;
+ this.firstRow = firstRow;
+ this.maxRows = maxRows;
this.entityMode = entityMode;
this.filters = filters;
- this.customTransformer = queryParameters.getResultTransformer();
- this.hashCode = getHashCode();
+ this.customTransformer = customTransformer;
+ this.hashCode = generateHashCode();
}
-
- public boolean equals(Object other) {
- if ( !( other instanceof QueryKey ) ) return false;
- QueryKey that = (QueryKey) other;
- if ( !sqlQueryString.equals(that.sqlQueryString) ) return false;
- if ( !EqualsHelper.equals(firstRow, that.firstRow) || !EqualsHelper.equals(maxRows, that.maxRows) ) return false;
- if ( !EqualsHelper.equals(customTransformer, that.customTransformer) ) return false;
- if (types==null) {
- if (that.types!=null) return false;
- }
- else {
- if (that.types==null) return false;
- if ( types.length!=that.types.length ) return false;
- for ( int i=0; i<types.length; i++ ) {
- if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) return false;
- if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) return false;
- }
- }
- if ( !EqualsHelper.equals(filters, that.filters) ) return false;
- if ( !EqualsHelper.equals(namedParameters, that.namedParameters) ) return false;
- return true;
+
+ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ this.hashCode = generateHashCode();
}
-
- public int hashCode() {
- return hashCode;
- }
-
- private int getHashCode() {
+
+ private int generateHashCode() {
int result = 13;
result = 37 * result + ( firstRow==null ? 0 : firstRow.hashCode() );
result = 37 * result + ( maxRows==null ? 0 : maxRows.hashCode() );
@@ -90,29 +160,79 @@
return result;
}
+ public boolean equals(Object other) {
+ if ( !( other instanceof QueryKey ) ) {
+ return false;
+ }
+ QueryKey that = ( QueryKey ) other;
+ if ( !sqlQueryString.equals( that.sqlQueryString ) ) {
+ return false;
+ }
+ if ( !EqualsHelper.equals( firstRow, that.firstRow ) || !EqualsHelper.equals( maxRows, that.maxRows ) ) {
+ return false;
+ }
+ if ( !EqualsHelper.equals( customTransformer, that.customTransformer ) ) {
+ return false;
+ }
+ if ( types == null ) {
+ if ( that.types != null ) {
+ return false;
+ }
+ }
+ else {
+ if ( that.types == null ) {
+ return false;
+ }
+ if ( types.length != that.types.length ) {
+ return false;
+ }
+ for ( int i = 0; i < types.length; i++ ) {
+ if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) {
+ return false;
+ }
+ if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) {
+ return false;
+ }
+ }
+ }
+
+ return EqualsHelper.equals( filters, that.filters )
+ && EqualsHelper.equals( namedParameters, that.namedParameters );
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
public String toString() {
StringBuffer buf = new StringBuffer()
- .append("sql: ")
- .append(sqlQueryString);
- if (values!=null) {
- buf.append("; parameters: ");
- for (int i=0; i<values.length; i++) {
+ .append( "sql: " )
+ .append( sqlQueryString );
+ if ( values != null ) {
+ buf.append( "; parameters: " );
+ for ( int i = 0; i < values.length; i++ ) {
buf.append( values[i] )
- .append(", ");
+ .append( ", " );
}
}
- if (namedParameters!=null) {
- buf.append("; named parameters: ")
- .append(namedParameters);
+ if ( namedParameters != null ) {
+ buf.append( "; named parameters: " )
+ .append( namedParameters );
}
- if (filters!=null) {
- buf.append("; filters: ")
- .append(filters);
+ if ( filters != null ) {
+ buf.append( "; filters: " )
+ .append( filters );
}
- if (firstRow!=null) buf.append("; first row: ").append(firstRow);
- if (maxRows!=null) buf.append("; max rows: ").append(maxRows);
- if (customTransformer!=null) buf.append("; transformer: ").append(customTransformer);
+ if ( firstRow != null ) {
+ buf.append( "; first row: " ).append( firstRow );
+ }
+ if ( maxRows != null ) {
+ buf.append( "; max rows: " ).append( maxRows );
+ }
+ if ( customTransformer != null ) {
+ buf.append( "; transformer: " ).append( customTransformer );
+ }
return buf.toString();
}
-
+
}
Modified: core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java 2009-06-01 18:54:44 UTC (rev 16652)
+++ core/branches/Branch_3_2/src/org/hibernate/loader/Loader.java 2009-06-01 20:36:35 UTC (rev 16653)
@@ -2117,15 +2117,15 @@
QueryCache queryCache = factory.getQueryCache( queryParameters.getCacheRegion() );
Set filterKeys = FilterKey.createFilterKeys(
- session.getEnabledFilters(),
+ session.getEnabledFilters(),
session.getEntityMode()
- );
- QueryKey key = new QueryKey(
+ );
+ QueryKey key = QueryKey.generateQueryKey(
getSQLString(),
queryParameters,
filterKeys,
- session.getEntityMode()
- );
+ session
+ );
List result = getResultFromQueryCache(
session,
@@ -2134,7 +2134,7 @@
resultTypes,
queryCache,
key
- );
+ );
if ( result == null ) {
result = doList( session, queryParameters );
@@ -2146,7 +2146,7 @@
queryCache,
key,
result
- );
+ );
}
return getResultList( result, queryParameters.getResultTransformer() );
Modified: core/branches/Branch_3_2/src/org/hibernate/util/CollectionHelper.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/util/CollectionHelper.java 2009-06-01 18:54:44 UTC (rev 16652)
+++ core/branches/Branch_3_2/src/org/hibernate/util/CollectionHelper.java 2009-06-01 20:36:35 UTC (rev 16653)
@@ -1,4 +1,26 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.util;
import java.util.ArrayList;
@@ -9,14 +31,30 @@
import java.util.Map;
/**
+ * Various help for handling collections.
+ *
* @author Gavin King
+ * @author Steve Ebersole
*/
public final class CollectionHelper {
public static final List EMPTY_LIST = Collections.unmodifiableList( new ArrayList(0) );
public static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList(0) );
public static final Map EMPTY_MAP = Collections.unmodifiableMap( new HashMap(0) );
-
- private CollectionHelper() {}
+ private CollectionHelper() {
+ }
+
+ /**
+ * Build a properly sized map, especially handling load size and load factor to prevent immediate resizing.
+ * <p/>
+ * Especially helpful for copy map contents.
+ *
+ * @param size The size to make the map.
+ * @return The sized map.
+ */
+ public static Map mapOfSize(int size) {
+ final int currentSize = (int) (size / 0.75f);
+ return new HashMap( Math.max( currentSize+ 1, 16), 0.75f );
+ }
}
15 years, 7 months
Hibernate SVN: r16652 - in core/trunk/core/src: main/java/org/hibernate/loader and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 14:54:44 -0400 (Mon, 01 Jun 2009)
New Revision: 16652
Modified:
core/trunk/core/src/main/java/org/hibernate/cache/QueryKey.java
core/trunk/core/src/main/java/org/hibernate/loader/Loader.java
core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java
core/trunk/core/src/test/java/org/hibernate/cache/QueryKeyTest.java
Log:
HHH-3383 - QueryKey is storing references to entities instead of identifiers
Modified: core/trunk/core/src/main/java/org/hibernate/cache/QueryKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/QueryKey.java 2009-06-01 15:38:24 UTC (rev 16651)
+++ core/trunk/core/src/main/java/org/hibernate/cache/QueryKey.java 2009-06-01 18:54:44 UTC (rev 16652)
@@ -28,13 +28,17 @@
import java.io.IOException;
import java.util.Map;
import java.util.Set;
+import java.util.Iterator;
import org.hibernate.EntityMode;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.RowSelection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.TypedValue;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.Type;
import org.hibernate.util.EqualsHelper;
+import org.hibernate.util.CollectionHelper;
/**
* A key that identifies a particular query with bound parameter values
@@ -59,12 +63,41 @@
*/
private transient int hashCode;
- public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
- this.sqlQueryString = queryString;
- this.types = queryParameters.getPositionalParameterTypes();
- this.values = queryParameters.getPositionalParameterValues();
- RowSelection selection = queryParameters.getRowSelection();
- if (selection!=null) {
+ public static QueryKey generateQueryKey(
+ String queryString,
+ QueryParameters queryParameters,
+ Set filters,
+ SessionImplementor session) {
+ // disassemble positional parameters
+ final int positionalParameterCount = queryParameters.getPositionalParameterTypes().length;
+ final Type[] types = new Type[positionalParameterCount];
+ final Object[] values = new Object[positionalParameterCount];
+ for ( int i = 0; i < positionalParameterCount; i++ ) {
+ types[i] = queryParameters.getPositionalParameterTypes()[i];
+ values[i] = types[i].disassemble( queryParameters.getPositionalParameterValues()[i], session, null );
+ }
+
+ // disassemble named parameters
+ Map namedParameters = CollectionHelper.mapOfSize( queryParameters.getNamedParameters().size() );
+ Iterator itr = queryParameters.getNamedParameters().entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final Map.Entry namedParameterEntry = ( Map.Entry ) itr.next();
+ final TypedValue original = ( TypedValue ) namedParameterEntry.getValue();
+ namedParameters.put(
+ namedParameterEntry.getKey(),
+ new TypedValue(
+ original.getType(),
+ original.getType().disassemble( original.getValue(), session, null ),
+ session.getEntityMode()
+ )
+ );
+ }
+
+ // decode row selection...
+ final RowSelection selection = queryParameters.getRowSelection();
+ final Integer firstRow;
+ final Integer maxRows;
+ if ( selection != null ) {
firstRow = selection.getFirstRow();
maxRows = selection.getMaxRows();
}
@@ -72,13 +105,62 @@
firstRow = null;
maxRows = null;
}
- this.namedParameters = queryParameters.getNamedParameters();
+
+ return new QueryKey(
+ queryString,
+ types,
+ values,
+ namedParameters,
+ firstRow,
+ maxRows,
+ filters,
+ session.getEntityMode(),
+ queryParameters.getResultTransformer()
+ );
+ }
+
+ /*package*/ QueryKey(
+ String sqlQueryString,
+ Type[] types,
+ Object[] values,
+ Map namedParameters,
+ Integer firstRow,
+ Integer maxRows,
+ Set filters,
+ EntityMode entityMode,
+ ResultTransformer customTransformer) {
+ this.sqlQueryString = sqlQueryString;
+ this.types = types;
+ this.values = values;
+ this.namedParameters = namedParameters;
+ this.firstRow = firstRow;
+ this.maxRows = maxRows;
this.entityMode = entityMode;
this.filters = filters;
- this.customTransformer = queryParameters.getResultTransformer();
+ this.customTransformer = customTransformer;
this.hashCode = generateHashCode();
}
+// public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
+// this.sqlQueryString = queryString;
+// this.types = queryParameters.getPositionalParameterTypes();
+// this.values = queryParameters.getPositionalParameterValues();
+// RowSelection selection = queryParameters.getRowSelection();
+// if (selection!=null) {
+// firstRow = selection.getFirstRow();
+// maxRows = selection.getMaxRows();
+// }
+// else {
+// firstRow = null;
+// maxRows = null;
+// }
+// this.namedParameters = queryParameters.getNamedParameters();
+// this.entityMode = entityMode;
+// this.filters = filters;
+// this.customTransformer = queryParameters.getResultTransformer();
+// this.hashCode = generateHashCode();
+// }
+
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
this.hashCode = generateHashCode();
@@ -99,25 +181,43 @@
}
public boolean equals(Object other) {
- if (!(other instanceof QueryKey)) return false;
- QueryKey that = (QueryKey) other;
- if ( !sqlQueryString.equals(that.sqlQueryString) ) return false;
- if ( !EqualsHelper.equals(firstRow, that.firstRow) || !EqualsHelper.equals(maxRows, that.maxRows) ) return false;
- if ( !EqualsHelper.equals(customTransformer, that.customTransformer) ) return false;
- if (types==null) {
- if (that.types!=null) return false;
+ if ( !( other instanceof QueryKey ) ) {
+ return false;
}
+ QueryKey that = ( QueryKey ) other;
+ if ( !sqlQueryString.equals( that.sqlQueryString ) ) {
+ return false;
+ }
+ if ( !EqualsHelper.equals( firstRow, that.firstRow ) || !EqualsHelper.equals( maxRows, that.maxRows ) ) {
+ return false;
+ }
+ if ( !EqualsHelper.equals( customTransformer, that.customTransformer ) ) {
+ return false;
+ }
+ if ( types == null ) {
+ if ( that.types != null ) {
+ return false;
+ }
+ }
else {
- if (that.types==null) return false;
- if ( types.length!=that.types.length ) return false;
- for ( int i=0; i<types.length; i++ ) {
- if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) return false;
- if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) return false;
+ if ( that.types == null ) {
+ return false;
}
+ if ( types.length != that.types.length ) {
+ return false;
+ }
+ for ( int i = 0; i < types.length; i++ ) {
+ if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) {
+ return false;
+ }
+ if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) {
+ return false;
+ }
+ }
}
- if ( !EqualsHelper.equals(filters, that.filters) ) return false;
- if ( !EqualsHelper.equals(namedParameters, that.namedParameters) ) return false;
- return true;
+
+ return EqualsHelper.equals( filters, that.filters )
+ && EqualsHelper.equals( namedParameters, that.namedParameters );
}
public int hashCode() {
@@ -126,26 +226,32 @@
public String toString() {
StringBuffer buf = new StringBuffer()
- .append("sql: ")
- .append(sqlQueryString);
- if (values!=null) {
- buf.append("; parameters: ");
- for (int i=0; i<values.length; i++) {
+ .append( "sql: " )
+ .append( sqlQueryString );
+ if ( values != null ) {
+ buf.append( "; parameters: " );
+ for ( int i = 0; i < values.length; i++ ) {
buf.append( values[i] )
- .append(", ");
+ .append( ", " );
}
}
- if (namedParameters!=null) {
- buf.append("; named parameters: ")
- .append(namedParameters);
+ if ( namedParameters != null ) {
+ buf.append( "; named parameters: " )
+ .append( namedParameters );
}
- if (filters!=null) {
- buf.append("; filters: ")
- .append(filters);
+ if ( filters != null ) {
+ buf.append( "; filters: " )
+ .append( filters );
}
- if (firstRow!=null) buf.append("; first row: ").append(firstRow);
- if (maxRows!=null) buf.append("; max rows: ").append(maxRows);
- if (customTransformer!=null) buf.append("; transformer: ").append(customTransformer);
+ if ( firstRow != null ) {
+ buf.append( "; first row: " ).append( firstRow );
+ }
+ if ( maxRows != null ) {
+ buf.append( "; max rows: " ).append( maxRows );
+ }
+ if ( customTransformer != null ) {
+ buf.append( "; transformer: " ).append( customTransformer );
+ }
return buf.toString();
}
Modified: core/trunk/core/src/main/java/org/hibernate/loader/Loader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/Loader.java 2009-06-01 15:38:24 UTC (rev 16651)
+++ core/trunk/core/src/main/java/org/hibernate/loader/Loader.java 2009-06-01 18:54:44 UTC (rev 16652)
@@ -2138,15 +2138,15 @@
QueryCache queryCache = factory.getQueryCache( queryParameters.getCacheRegion() );
Set filterKeys = FilterKey.createFilterKeys(
- session.getEnabledFilters(),
+ session.getLoadQueryInfluencers().getEnabledFilters(),
session.getEntityMode()
- );
- QueryKey key = new QueryKey(
+ );
+ QueryKey key = QueryKey.generateQueryKey(
getSQLString(),
queryParameters,
filterKeys,
- session.getEntityMode()
- );
+ session
+ );
List result = getResultFromQueryCache(
session,
@@ -2155,7 +2155,7 @@
resultTypes,
queryCache,
key
- );
+ );
if ( result == null ) {
result = doList( session, queryParameters );
@@ -2167,7 +2167,7 @@
queryCache,
key,
result
- );
+ );
}
return getResultList( result, queryParameters.getResultTransformer() );
Modified: core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java 2009-06-01 15:38:24 UTC (rev 16651)
+++ core/trunk/core/src/main/java/org/hibernate/util/CollectionHelper.java 2009-06-01 18:54:44 UTC (rev 16652)
@@ -42,4 +42,8 @@
private CollectionHelper() {}
+ public static Map mapOfSize(int size) {
+ final int currentSize = (int) (size / 0.75f);
+ return new HashMap( Math.max( currentSize+ 1, 16), 0.75f );
+ }
}
Modified: core/trunk/core/src/test/java/org/hibernate/cache/QueryKeyTest.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/cache/QueryKeyTest.java 2009-06-01 15:38:24 UTC (rev 16651)
+++ core/trunk/core/src/test/java/org/hibernate/cache/QueryKeyTest.java 2009-06-01 18:54:44 UTC (rev 16652)
@@ -29,7 +29,6 @@
import junit.framework.TestCase;
-import org.hibernate.engine.QueryParameters;
import org.hibernate.EntityMode;
import org.hibernate.transform.RootEntityResultTransformer;
import org.hibernate.transform.ResultTransformer;
@@ -49,35 +48,31 @@
private static final String QUERY_STRING = "the query string";
public void testSerializedEquality() {
- doTest( buildBasicKey( new QueryParameters() ) );
+ doTest( buildBasicKey( null ) );
}
public void testSerializedEqualityWithResultTransformer() {
- doTest( buildBasicKey( buildQueryParameters( RootEntityResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( DistinctRootEntityResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( DistinctResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( AliasToEntityMapResultTransformer.INSTANCE ) ) );
- doTest( buildBasicKey( buildQueryParameters( PassThroughResultTransformer.INSTANCE ) ) );
+ doTest( buildBasicKey( RootEntityResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( DistinctRootEntityResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( DistinctResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( AliasToEntityMapResultTransformer.INSTANCE ) );
+ doTest( buildBasicKey( PassThroughResultTransformer.INSTANCE ) );
}
- private QueryParameters buildQueryParameters(ResultTransformer resultTransformer) {
- return new QueryParameters(
- ArrayHelper.EMPTY_TYPE_ARRAY, // param types
- ArrayHelper.EMPTY_OBJECT_ARRAY, // param values
- Collections.EMPTY_MAP, // lock modes
- null, // row selection
- false, // cacheable?
- "", // cache region
- "", // SQL comment
- false, // is natural key lookup?
- resultTransformer // the result transformer, duh! ;)
+ private QueryKey buildBasicKey(ResultTransformer resultTransformer) {
+ return new QueryKey(
+ QUERY_STRING,
+ ArrayHelper.EMPTY_TYPE_ARRAY, // positional param types
+ ArrayHelper.EMPTY_OBJECT_ARRAY, // positional param values
+ Collections.EMPTY_MAP, // named params
+ null, // firstRow selection
+ null, // maxRows selection
+ Collections.EMPTY_SET, // filter keys
+ EntityMode.POJO, // entity mode
+ resultTransformer // the result transformer
);
}
- private QueryKey buildBasicKey(QueryParameters queryParameters) {
- return new QueryKey( QUERY_STRING, queryParameters, Collections.EMPTY_SET, EntityMode.POJO );
- }
-
private void doTest(QueryKey key) {
HashMap map = new HashMap();
15 years, 7 months
Hibernate SVN: r16651 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:38:24 -0400 (Mon, 01 Jun 2009)
New Revision: 16651
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes (formatting)
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:38:08 UTC (rev 16650)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:38:24 UTC (rev 16651)
@@ -86,8 +86,10 @@
// select topic, syntax from information_schema.help
// where section like 'Function%' order by section, topic
+ //
+ // see also -> http://www.h2database.com/html/functions.html
-// registerFunction("abs", new StandardSQLFunction("abs"));
+ // Numeric Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
@@ -97,13 +99,17 @@
registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
-// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
@@ -112,28 +118,17 @@
registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
-// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );
- registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
- registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
- registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
- registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
- registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
-
+ // String Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
-// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
- registerFunction( "lower", new StandardSQLFunction( "lower", Hibernate.STRING ) );
registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
-// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
-// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
-// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
@@ -147,13 +142,14 @@
registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
-// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
-// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
-
registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
+ registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );
+ // Time and Date Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
@@ -162,25 +158,16 @@
registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
-// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
-// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
-// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
-// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
-// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
- registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
- registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
- registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
- registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
-
+ // System Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
-
}
public String getAddColumnString() {
15 years, 7 months
Hibernate SVN: r16650 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:38:08 -0400 (Mon, 01 Jun 2009)
New Revision: 16650
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:37:38 UTC (rev 16649)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:38:08 UTC (rev 16650)
@@ -86,8 +86,10 @@
// select topic, syntax from information_schema.help
// where section like 'Function%' order by section, topic
+ //
+ // see also -> http://www.h2database.com/html/functions.html
-// registerFunction("abs", new StandardSQLFunction("abs"));
+ // Numeric Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
@@ -97,13 +99,17 @@
registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
-// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
@@ -112,28 +118,17 @@
registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
-// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );
- registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
- registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
- registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
- registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
- registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
-
+ // String Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
-// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
- registerFunction( "lower", new StandardSQLFunction( "lower", Hibernate.STRING ) );
registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
-// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
-// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
-// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
@@ -147,13 +142,14 @@
registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
-// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
-// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
-
registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
+ registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );
+ // Time and Date Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
@@ -162,20 +158,12 @@
registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
-// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
-// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
-// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
-// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
-// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
- registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
- registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
- registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
- registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
-
+ // System Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
15 years, 7 months
Hibernate SVN: r16649 - core/branches/Branch_3_2/src/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:37:38 -0400 (Mon, 01 Jun 2009)
New Revision: 16649
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:24:51 UTC (rev 16648)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:37:38 UTC (rev 16649)
@@ -64,8 +64,10 @@
// select topic, syntax from information_schema.help
// where section like 'Function%' order by section, topic
+ //
+ // see also -> http://www.h2database.com/html/functions.html
-// registerFunction("abs", new StandardSQLFunction("abs"));
+ // Numeric Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
@@ -75,13 +77,17 @@
registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
-// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
@@ -90,28 +96,17 @@
registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
-// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );
- registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
- registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
- registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
- registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
- registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
-
+ // String Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
-// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
- registerFunction( "lower", new StandardSQLFunction( "lower", Hibernate.STRING ) );
registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
-// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
-// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
-// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
@@ -125,13 +120,14 @@
registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
-// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
-// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
-
registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
+ registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );
+ // Time and Date Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
@@ -140,20 +136,12 @@
registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
-// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
-// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
-// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
-// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
-// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
- registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
- registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
- registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
- registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
-
+ // System Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
15 years, 7 months
Hibernate SVN: r16648 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:24:51 -0400 (Mon, 01 Jun 2009)
New Revision: 16648
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes (formatting)
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:24:20 UTC (rev 16647)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:24:51 UTC (rev 16648)
@@ -37,7 +37,7 @@
/**
* A dialect compatible with the H2 database.
- *
+ *
* @author Thomas Mueller
*/
public class H2Dialect extends Dialect {
@@ -61,212 +61,212 @@
// ignore (probably H2 not in the classpath)
}
- registerColumnType(Types.BOOLEAN, "boolean");
- registerColumnType(Types.BIGINT, "bigint");
- registerColumnType(Types.BINARY, "binary");
- registerColumnType(Types.BIT, "boolean");
- registerColumnType(Types.CHAR, "char($l)");
- registerColumnType(Types.DATE, "date");
- registerColumnType(Types.DECIMAL, "decimal($p,$s)");
- registerColumnType(Types.DOUBLE, "double");
- registerColumnType(Types.FLOAT, "float");
- registerColumnType(Types.INTEGER, "integer");
- registerColumnType(Types.LONGVARBINARY, "longvarbinary");
- registerColumnType(Types.LONGVARCHAR, "longvarchar");
- registerColumnType(Types.REAL, "real");
- registerColumnType(Types.SMALLINT, "smallint");
- registerColumnType(Types.TINYINT, "tinyint");
- registerColumnType(Types.TIME, "time");
- registerColumnType(Types.TIMESTAMP, "timestamp");
- registerColumnType(Types.VARCHAR, "varchar($l)");
- registerColumnType(Types.VARBINARY, "binary($l)");
- registerColumnType(Types.NUMERIC, "numeric");
- registerColumnType(Types.BLOB, "blob");
- registerColumnType(Types.CLOB, "clob");
-
- // select topic, syntax from information_schema.help
- // where section like 'Function%' order by section, topic
+ registerColumnType( Types.BOOLEAN, "boolean" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.BINARY, "binary" );
+ registerColumnType( Types.BIT, "boolean" );
+ registerColumnType( Types.CHAR, "char($l)" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.LONGVARBINARY, "longvarbinary" );
+ registerColumnType( Types.LONGVARCHAR, "longvarchar" );
+ registerColumnType( Types.REAL, "real" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.VARBINARY, "binary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+ // select topic, syntax from information_schema.help
+ // where section like 'Function%' order by section, topic
+
// registerFunction("abs", new StandardSQLFunction("abs"));
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE));
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE));
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE));
- registerFunction("atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE));
- registerFunction("bitand", new StandardSQLFunction("bitand", Hibernate.INTEGER));
- registerFunction("bitor", new StandardSQLFunction("bitor", Hibernate.INTEGER));
- registerFunction("bitxor", new StandardSQLFunction("bitxor", Hibernate.INTEGER));
- registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.DOUBLE));
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE));
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE));
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE));
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE));
- registerFunction("floor", new StandardSQLFunction("floor", Hibernate.DOUBLE));
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE));
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE));
+ registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
+ registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
+ registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
+ registerFunction( "atan2", new StandardSQLFunction( "atan2", Hibernate.DOUBLE ) );
+ registerFunction( "bitand", new StandardSQLFunction( "bitand", Hibernate.INTEGER ) );
+ registerFunction( "bitor", new StandardSQLFunction( "bitor", Hibernate.INTEGER ) );
+ registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
+ registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
+ registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
+ registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
- registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE));
- registerFunction("power", new StandardSQLFunction("power", Hibernate.DOUBLE));
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE));
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE));
- registerFunction("round", new StandardSQLFunction("round", Hibernate.DOUBLE));
- registerFunction("roundmagic", new StandardSQLFunction("roundmagic", Hibernate.DOUBLE));
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER));
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE));
+ registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
+ registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
+ registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
+ registerFunction( "rand", new NoArgSQLFunction( "rand", Hibernate.DOUBLE ) );
+ registerFunction( "round", new StandardSQLFunction( "round", Hibernate.DOUBLE ) );
+ registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
+ registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
+ registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE));
- registerFunction("truncate", new StandardSQLFunction("truncate", Hibernate.DOUBLE));
+ registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
+ registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );
- registerFunction("compress", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("expand", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("decrypt", new StandardSQLFunction("decrypt", Hibernate.BINARY));
- registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.BINARY));
- registerFunction("hash", new StandardSQLFunction("hash", Hibernate.BINARY));
+ registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
+ registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
+ registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
+ registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
- registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER));
+ registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
- registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER));
- registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "(", "||", ")"));
- registerFunction("difference", new StandardSQLFunction("difference", Hibernate.INTEGER));
- registerFunction("hextoraw", new StandardSQLFunction("hextoraw", Hibernate.STRING));
- registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("insert", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("left", new StandardSQLFunction("left", Hibernate.STRING));
+ registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+ registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
+ registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
+ registerFunction( "lower", new StandardSQLFunction( "lower", Hibernate.STRING ) );
+ registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
+ registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("lcase", new StandardSQLFunction("lcase", Hibernate.STRING));
- registerFunction("ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING));
- registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.INTEGER));
- registerFunction("position", new StandardSQLFunction("position", Hibernate.INTEGER));
- registerFunction("rawtohex", new StandardSQLFunction("rawtohex", Hibernate.STRING));
- registerFunction("repeat", new StandardSQLFunction("repeat", Hibernate.STRING));
- registerFunction("replace", new StandardSQLFunction("replace", Hibernate.STRING));
- registerFunction("right", new StandardSQLFunction("right", Hibernate.STRING));
- registerFunction("rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING));
- registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING));
- registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING));
- registerFunction("stringencode", new StandardSQLFunction("stringencode", Hibernate.STRING));
- registerFunction("stringdecode", new StandardSQLFunction("stringdecode", Hibernate.STRING));
+ registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
+ registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
+ registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
+ registerFunction( "position", new StandardSQLFunction( "position", Hibernate.INTEGER ) );
+ registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex", Hibernate.STRING ) );
+ registerFunction( "repeat", new StandardSQLFunction( "repeat", Hibernate.STRING ) );
+ registerFunction( "replace", new StandardSQLFunction( "replace", Hibernate.STRING ) );
+ registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
+ registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
+ registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
+ registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
+ registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
+ registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction("ucase", new StandardSQLFunction("ucase", Hibernate.STRING));
+ registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
- registerFunction("stringtoutf8", new StandardSQLFunction("stringtoutf8", Hibernate.BINARY));
- registerFunction("utf8tostring", new StandardSQLFunction("utf8tostring", Hibernate.STRING));
+ registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
+ registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );
- registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
- registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
- registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
- registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER));
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER));
+ registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
+ registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
+ registerFunction( "datediff", new StandardSQLFunction( "datediff", Hibernate.INTEGER ) );
+ registerFunction( "dayname", new StandardSQLFunction( "dayname", Hibernate.STRING ) );
+ registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
+ registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
+ registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
+ registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
+ registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
- registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE));
- registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME));
- registerFunction("curtimestamp", new NoArgSQLFunction("curtimestamp", Hibernate.TIME));
- registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP));
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
- registerFunction("database", new NoArgSQLFunction("database", Hibernate.STRING));
- registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
+ registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
+ registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
- }
+ }
- public String getAddColumnString() {
- return "add column";
- }
+ public String getAddColumnString() {
+ return "add column";
+ }
- public boolean supportsIdentityColumns() {
- return true;
- }
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
- public String getIdentityColumnString() {
- return "generated by default as identity"; // not null is implicit
- }
+ public String getIdentityColumnString() {
+ return "generated by default as identity"; // not null is implicit
+ }
- public String getIdentitySelectString() {
- return "call identity()";
- }
+ public String getIdentitySelectString() {
+ return "call identity()";
+ }
- public String getIdentityInsertString() {
- return "null";
- }
+ public String getIdentityInsertString() {
+ return "null";
+ }
- public String getForUpdateString() {
- return " for update";
- }
+ public String getForUpdateString() {
+ return " for update";
+ }
- public boolean supportsUnique() {
- return true;
- }
+ public boolean supportsUnique() {
+ return true;
+ }
- public boolean supportsLimit() {
- return true;
- }
+ public boolean supportsLimit() {
+ return true;
+ }
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer(sql.length() + 20)
- .append(sql)
- .append(hasOffset ? " limit ? offset ?" : " limit ?")
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length() + 20 )
+ .append( sql )
+ .append( hasOffset ? " limit ? offset ?" : " limit ?" )
.toString();
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
+ }
- public boolean bindLimitParametersFirst() {
- return false;
- }
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
- public boolean supportsIfExistsAfterTableName() {
- return true;
- }
+ public boolean bindLimitParametersFirst() {
+ return false;
+ }
- public boolean supportsSequences() {
- return true;
- }
+ public boolean supportsIfExistsAfterTableName() {
+ return true;
+ }
+ public boolean supportsSequences() {
+ return true;
+ }
+
public boolean supportsPooledSequences() {
return true;
}
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
- public String getSelectSequenceNextValString(String sequenceName) {
- return "next value for " + sequenceName;
- }
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "next value for " + sequenceName;
+ }
- public String getSequenceNextValString(String sequenceName) {
- return "call next value for " + sequenceName;
- }
+ public String getSequenceNextValString(String sequenceName) {
+ return "call next value for " + sequenceName;
+ }
- public String getQuerySequencesString() {
- return querySequenceString;
- }
+ public String getQuerySequencesString() {
+ return querySequenceString;
+ }
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
+ return EXTRACTER;
+ }
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
/**
* Extract the name of the violated constraint from the given SQLException.
*
@@ -288,31 +288,31 @@
}
};
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "create temporary table if not exists";
- }
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "call current_timestamp()";
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
+ public String getCreateTemporaryTableString() {
+ return "create temporary table if not exists";
+ }
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "call current_timestamp()";
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean supportsLobValueChangePropogation() {
15 years, 7 months
Hibernate SVN: r16647 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:24:20 -0400 (Mon, 01 Jun 2009)
New Revision: 16647
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes (formatting)
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:23:20 UTC (rev 16646)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:24:20 UTC (rev 16647)
@@ -37,15 +37,15 @@
/**
* A dialect compatible with the H2 database.
- *
+ *
* @author Thomas Mueller
*/
public class H2Dialect extends Dialect {
- private String querySequenceString;
+ private String querySequenceString;
- public H2Dialect() {
- super();
+ public H2Dialect() {
+ super();
querySequenceString = "select sequence_name from information_schema.sequences";
try {
@@ -61,218 +61,218 @@
// ignore (probably H2 not in the classpath)
}
- registerColumnType(Types.BOOLEAN, "boolean");
- registerColumnType(Types.BIGINT, "bigint");
- registerColumnType(Types.BINARY, "binary");
- registerColumnType(Types.BIT, "boolean");
- registerColumnType(Types.CHAR, "char($l)");
- registerColumnType(Types.DATE, "date");
- registerColumnType(Types.DECIMAL, "decimal($p,$s)");
- registerColumnType(Types.DOUBLE, "double");
- registerColumnType(Types.FLOAT, "float");
- registerColumnType(Types.INTEGER, "integer");
- registerColumnType(Types.LONGVARBINARY, "longvarbinary");
- registerColumnType(Types.LONGVARCHAR, "longvarchar");
- registerColumnType(Types.REAL, "real");
- registerColumnType(Types.SMALLINT, "smallint");
- registerColumnType(Types.TINYINT, "tinyint");
- registerColumnType(Types.TIME, "time");
- registerColumnType(Types.TIMESTAMP, "timestamp");
- registerColumnType(Types.VARCHAR, "varchar($l)");
- registerColumnType(Types.VARBINARY, "binary($l)");
- registerColumnType(Types.NUMERIC, "numeric");
- registerColumnType(Types.BLOB, "blob");
- registerColumnType(Types.CLOB, "clob");
-
- // select topic, syntax from information_schema.help
- // where section like 'Function%' order by section, topic
+ registerColumnType( Types.BOOLEAN, "boolean" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.BINARY, "binary" );
+ registerColumnType( Types.BIT, "boolean" );
+ registerColumnType( Types.CHAR, "char($l)" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.LONGVARBINARY, "longvarbinary" );
+ registerColumnType( Types.LONGVARCHAR, "longvarchar" );
+ registerColumnType( Types.REAL, "real" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.VARBINARY, "binary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+ // select topic, syntax from information_schema.help
+ // where section like 'Function%' order by section, topic
+
// registerFunction("abs", new StandardSQLFunction("abs"));
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE));
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE));
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE));
- registerFunction("atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE));
- registerFunction("bitand", new StandardSQLFunction("bitand", Hibernate.INTEGER));
- registerFunction("bitor", new StandardSQLFunction("bitor", Hibernate.INTEGER));
- registerFunction("bitxor", new StandardSQLFunction("bitxor", Hibernate.INTEGER));
- registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.DOUBLE));
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE));
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE));
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE));
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE));
- registerFunction("floor", new StandardSQLFunction("floor", Hibernate.DOUBLE));
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE));
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE));
+ registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
+ registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
+ registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
+ registerFunction( "atan2", new StandardSQLFunction( "atan2", Hibernate.DOUBLE ) );
+ registerFunction( "bitand", new StandardSQLFunction( "bitand", Hibernate.INTEGER ) );
+ registerFunction( "bitor", new StandardSQLFunction( "bitor", Hibernate.INTEGER ) );
+ registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
+ registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
+ registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
+ registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
- registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE));
- registerFunction("power", new StandardSQLFunction("power", Hibernate.DOUBLE));
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE));
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE));
- registerFunction("round", new StandardSQLFunction("round", Hibernate.DOUBLE));
- registerFunction("roundmagic", new StandardSQLFunction("roundmagic", Hibernate.DOUBLE));
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER));
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE));
+ registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
+ registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
+ registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
+ registerFunction( "rand", new NoArgSQLFunction( "rand", Hibernate.DOUBLE ) );
+ registerFunction( "round", new StandardSQLFunction( "round", Hibernate.DOUBLE ) );
+ registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
+ registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
+ registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE));
- registerFunction("truncate", new StandardSQLFunction("truncate", Hibernate.DOUBLE));
+ registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
+ registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );
- registerFunction("compress", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("expand", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("decrypt", new StandardSQLFunction("decrypt", Hibernate.BINARY));
- registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.BINARY));
- registerFunction("hash", new StandardSQLFunction("hash", Hibernate.BINARY));
+ registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
+ registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
+ registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
+ registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
- registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER));
+ registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
- registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER));
- registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "(", "||", ")"));
- registerFunction("difference", new StandardSQLFunction("difference", Hibernate.INTEGER));
- registerFunction("hextoraw", new StandardSQLFunction("hextoraw", Hibernate.STRING));
- registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("insert", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("left", new StandardSQLFunction("left", Hibernate.STRING));
+ registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+ registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
+ registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
+ registerFunction( "lower", new StandardSQLFunction( "lower", Hibernate.STRING ) );
+ registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
+ registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("lcase", new StandardSQLFunction("lcase", Hibernate.STRING));
- registerFunction("ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING));
- registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.INTEGER));
- registerFunction("position", new StandardSQLFunction("position", Hibernate.INTEGER));
- registerFunction("rawtohex", new StandardSQLFunction("rawtohex", Hibernate.STRING));
- registerFunction("repeat", new StandardSQLFunction("repeat", Hibernate.STRING));
- registerFunction("replace", new StandardSQLFunction("replace", Hibernate.STRING));
- registerFunction("right", new StandardSQLFunction("right", Hibernate.STRING));
- registerFunction("rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING));
- registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING));
- registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING));
- registerFunction("stringencode", new StandardSQLFunction("stringencode", Hibernate.STRING));
- registerFunction("stringdecode", new StandardSQLFunction("stringdecode", Hibernate.STRING));
+ registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
+ registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
+ registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
+ registerFunction( "position", new StandardSQLFunction( "position", Hibernate.INTEGER ) );
+ registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex", Hibernate.STRING ) );
+ registerFunction( "repeat", new StandardSQLFunction( "repeat", Hibernate.STRING ) );
+ registerFunction( "replace", new StandardSQLFunction( "replace", Hibernate.STRING ) );
+ registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
+ registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
+ registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
+ registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
+ registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
+ registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction("ucase", new StandardSQLFunction("ucase", Hibernate.STRING));
+ registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
- registerFunction("stringtoutf8", new StandardSQLFunction("stringtoutf8", Hibernate.BINARY));
- registerFunction("utf8tostring", new StandardSQLFunction("utf8tostring", Hibernate.STRING));
+ registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
+ registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );
- registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
- registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
- registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
- registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER));
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER));
+ registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
+ registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
+ registerFunction( "datediff", new StandardSQLFunction( "datediff", Hibernate.INTEGER ) );
+ registerFunction( "dayname", new StandardSQLFunction( "dayname", Hibernate.STRING ) );
+ registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
+ registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
+ registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
+ registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
+ registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
- registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE));
- registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME));
- registerFunction("curtimestamp", new NoArgSQLFunction("curtimestamp", Hibernate.TIME));
- registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP));
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
- registerFunction("database", new NoArgSQLFunction("database", Hibernate.STRING));
- registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
+ registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
+ registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
- }
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
+ }
- public String getAddColumnString() {
- return "add column";
- }
+ public String getAddColumnString() {
+ return "add column";
+ }
- public boolean supportsIdentityColumns() {
- return true;
- }
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
- public String getIdentityColumnString() {
- return "generated by default as identity"; // not null is implicit
- }
+ public String getIdentityColumnString() {
+ return "generated by default as identity"; // not null is implicit
+ }
- public String getIdentitySelectString() {
- return "call identity()";
- }
+ public String getIdentitySelectString() {
+ return "call identity()";
+ }
- public String getIdentityInsertString() {
- return "null";
- }
+ public String getIdentityInsertString() {
+ return "null";
+ }
- public String getForUpdateString() {
- return " for update";
- }
+ public String getForUpdateString() {
+ return " for update";
+ }
- public boolean supportsUnique() {
- return true;
- }
+ public boolean supportsUnique() {
+ return true;
+ }
- public boolean supportsLimit() {
- return true;
- }
+ public boolean supportsLimit() {
+ return true;
+ }
- public String getLimitString(String sql, boolean hasOffset) {
+ public String getLimitString(String sql, boolean hasOffset) {
return new StringBuffer( sql.length() + 20 )
.append( sql )
.append( hasOffset ? " limit ? offset ?" : " limit ?" )
.toString();
}
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
- public boolean bindLimitParametersFirst() {
- return false;
- }
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
- public boolean supportsIfExistsAfterTableName() {
- return true;
- }
+ public boolean bindLimitParametersFirst() {
+ return false;
+ }
- public boolean supportsSequences() {
- return true;
- }
+ public boolean supportsIfExistsAfterTableName() {
+ return true;
+ }
+ public boolean supportsSequences() {
+ return true;
+ }
+
public boolean supportsPooledSequences() {
return true;
}
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
- public String getSelectSequenceNextValString(String sequenceName) {
- return "next value for " + sequenceName;
- }
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "next value for " + sequenceName;
+ }
- public String getSequenceNextValString(String sequenceName) {
- return "call next value for " + sequenceName;
- }
+ public String getSequenceNextValString(String sequenceName) {
+ return "call next value for " + sequenceName;
+ }
- public String getQuerySequencesString() {
- return querySequenceString;
- }
+ public String getQuerySequencesString() {
+ return querySequenceString;
+ }
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
+ return EXTRACTER;
+ }
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
String constraintName = null;
// 23000: Check constraint violation: {0}
// 23001: Unique index or primary key violation: {0}
@@ -284,34 +284,34 @@
}
}
return constraintName;
- }
- };
+ }
+ };
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "create temporary table if not exists";
- }
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "call current_timestamp()";
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
+ public String getCreateTemporaryTableString() {
+ return "create temporary table if not exists";
+ }
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "call current_timestamp()";
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean supportsLobValueChangePropogation() {
15 years, 7 months
Hibernate SVN: r16646 - core/branches/Branch_3_2/src/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:23:20 -0400 (Mon, 01 Jun 2009)
New Revision: 16646
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes (formatting)
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:22:07 UTC (rev 16645)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:23:20 UTC (rev 16646)
@@ -20,12 +20,12 @@
*/
public class H2Dialect extends Dialect {
- private String querySequenceString;
+ private String querySequenceString;
- public H2Dialect() {
- super();
+ public H2Dialect() {
+ super();
- querySequenceString = "select sequence_name from information_schema.sequences";
+ querySequenceString = "select sequence_name from information_schema.sequences";
try {
// HHH-2300
Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
@@ -39,178 +39,178 @@
// ignore (probably H2 not in the classpath)
}
- registerColumnType(Types.BOOLEAN, "boolean");
- registerColumnType(Types.BIGINT, "bigint");
- registerColumnType(Types.BINARY, "binary");
- registerColumnType(Types.BIT, "boolean");
- registerColumnType(Types.CHAR, "char($l)");
- registerColumnType(Types.DATE, "date");
- registerColumnType(Types.DECIMAL, "decimal($p,$s)");
- registerColumnType(Types.DOUBLE, "double");
- registerColumnType(Types.FLOAT, "float");
- registerColumnType(Types.INTEGER, "integer");
- registerColumnType(Types.LONGVARBINARY, "longvarbinary");
- registerColumnType(Types.LONGVARCHAR, "longvarchar");
- registerColumnType(Types.REAL, "real");
- registerColumnType(Types.SMALLINT, "smallint");
- registerColumnType(Types.TINYINT, "tinyint");
- registerColumnType(Types.TIME, "time");
- registerColumnType(Types.TIMESTAMP, "timestamp");
- registerColumnType(Types.VARCHAR, "varchar($l)");
- registerColumnType(Types.VARBINARY, "binary($l)");
- registerColumnType(Types.NUMERIC, "numeric");
- registerColumnType(Types.BLOB, "blob");
- registerColumnType(Types.CLOB, "clob");
+ registerColumnType( Types.BOOLEAN, "boolean" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.BINARY, "binary" );
+ registerColumnType( Types.BIT, "boolean" );
+ registerColumnType( Types.CHAR, "char($l)" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.LONGVARBINARY, "longvarbinary" );
+ registerColumnType( Types.LONGVARCHAR, "longvarchar" );
+ registerColumnType( Types.REAL, "real" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.VARBINARY, "binary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
- // select topic, syntax from information_schema.help
- // where section like 'Function%' order by section, topic
+ // select topic, syntax from information_schema.help
+ // where section like 'Function%' order by section, topic
// registerFunction("abs", new StandardSQLFunction("abs"));
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE));
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE));
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE));
- registerFunction("atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE));
- registerFunction("bitand", new StandardSQLFunction("bitand", Hibernate.INTEGER));
- registerFunction("bitor", new StandardSQLFunction("bitor", Hibernate.INTEGER));
- registerFunction("bitxor", new StandardSQLFunction("bitxor", Hibernate.INTEGER));
- registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.DOUBLE));
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE));
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE));
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE));
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE));
- registerFunction("floor", new StandardSQLFunction("floor", Hibernate.DOUBLE));
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE));
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE));
+ registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
+ registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
+ registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
+ registerFunction( "atan2", new StandardSQLFunction( "atan2", Hibernate.DOUBLE ) );
+ registerFunction( "bitand", new StandardSQLFunction( "bitand", Hibernate.INTEGER ) );
+ registerFunction( "bitor", new StandardSQLFunction( "bitor", Hibernate.INTEGER ) );
+ registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
+ registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
+ registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
+ registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
- registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE));
- registerFunction("power", new StandardSQLFunction("power", Hibernate.DOUBLE));
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE));
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE));
- registerFunction("round", new StandardSQLFunction("round", Hibernate.DOUBLE));
- registerFunction("roundmagic", new StandardSQLFunction("roundmagic", Hibernate.DOUBLE));
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER));
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE));
+ registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
+ registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
+ registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
+ registerFunction( "rand", new NoArgSQLFunction( "rand", Hibernate.DOUBLE ) );
+ registerFunction( "round", new StandardSQLFunction( "round", Hibernate.DOUBLE ) );
+ registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
+ registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
+ registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE));
- registerFunction("truncate", new StandardSQLFunction("truncate", Hibernate.DOUBLE));
+ registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
+ registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );
- registerFunction("compress", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("expand", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("decrypt", new StandardSQLFunction("decrypt", Hibernate.BINARY));
- registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.BINARY));
- registerFunction("hash", new StandardSQLFunction("hash", Hibernate.BINARY));
+ registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
+ registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
+ registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
+ registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
- registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER));
+ registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
- registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER));
- registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "(", "||", ")"));
- registerFunction("difference", new StandardSQLFunction("difference", Hibernate.INTEGER));
- registerFunction("hextoraw", new StandardSQLFunction("hextoraw", Hibernate.STRING));
- registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("insert", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("left", new StandardSQLFunction("left", Hibernate.STRING));
+ registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+ registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
+ registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
+ registerFunction( "lower", new StandardSQLFunction( "lower", Hibernate.STRING ) );
+ registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
+ registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("lcase", new StandardSQLFunction("lcase", Hibernate.STRING));
- registerFunction("ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING));
- registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.INTEGER));
- registerFunction("position", new StandardSQLFunction("position", Hibernate.INTEGER));
- registerFunction("rawtohex", new StandardSQLFunction("rawtohex", Hibernate.STRING));
- registerFunction("repeat", new StandardSQLFunction("repeat", Hibernate.STRING));
- registerFunction("replace", new StandardSQLFunction("replace", Hibernate.STRING));
- registerFunction("right", new StandardSQLFunction("right", Hibernate.STRING));
- registerFunction("rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING));
- registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING));
- registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING));
- registerFunction("stringencode", new StandardSQLFunction("stringencode", Hibernate.STRING));
- registerFunction("stringdecode", new StandardSQLFunction("stringdecode", Hibernate.STRING));
+ registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
+ registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
+ registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
+ registerFunction( "position", new StandardSQLFunction( "position", Hibernate.INTEGER ) );
+ registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex", Hibernate.STRING ) );
+ registerFunction( "repeat", new StandardSQLFunction( "repeat", Hibernate.STRING ) );
+ registerFunction( "replace", new StandardSQLFunction( "replace", Hibernate.STRING ) );
+ registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
+ registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
+ registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
+ registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
+ registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
+ registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction("ucase", new StandardSQLFunction("ucase", Hibernate.STRING));
+ registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
- registerFunction("stringtoutf8", new StandardSQLFunction("stringtoutf8", Hibernate.BINARY));
- registerFunction("utf8tostring", new StandardSQLFunction("utf8tostring", Hibernate.STRING));
+ registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
+ registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );
- registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
- registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
- registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
- registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER));
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER));
+ registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
+ registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
+ registerFunction( "datediff", new StandardSQLFunction( "datediff", Hibernate.INTEGER ) );
+ registerFunction( "dayname", new StandardSQLFunction( "dayname", Hibernate.STRING ) );
+ registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
+ registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
+ registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
+ registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
+ registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
- registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE));
- registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME));
- registerFunction("curtimestamp", new NoArgSQLFunction("curtimestamp", Hibernate.TIME));
- registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP));
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
- registerFunction("database", new NoArgSQLFunction("database", Hibernate.STRING));
- registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
+ registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
+ registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
- }
+ }
- public String getAddColumnString() {
- return "add column";
- }
+ public String getAddColumnString() {
+ return "add column";
+ }
- public boolean supportsIdentityColumns() {
- return true;
- }
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
- public String getIdentityColumnString() {
- return "generated by default as identity"; // not null is implicit
- }
+ public String getIdentityColumnString() {
+ return "generated by default as identity"; // not null is implicit
+ }
- public String getIdentitySelectString() {
- return "call identity()";
- }
+ public String getIdentitySelectString() {
+ return "call identity()";
+ }
- public String getIdentityInsertString() {
- return "null";
- }
+ public String getIdentityInsertString() {
+ return "null";
+ }
- public String getForUpdateString() {
- return " for update";
- }
+ public String getForUpdateString() {
+ return " for update";
+ }
- public boolean supportsUnique() {
- return true;
- }
+ public boolean supportsUnique() {
+ return true;
+ }
- public boolean supportsLimit() {
- return true;
- }
+ public boolean supportsLimit() {
+ return true;
+ }
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer(sql.length() + 20)
- .append(sql)
- .append(hasOffset ? " limit ? offset ?" : " limit ?")
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length() + 20 )
+ .append( sql )
+ .append( hasOffset ? " limit ? offset ?" : " limit ?" )
.toString();
- }
+ }
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
- public boolean bindLimitParametersFirst() {
- return false;
- }
+ public boolean bindLimitParametersFirst() {
+ return false;
+ }
- public boolean supportsIfExistsAfterTableName() {
- return true;
- }
+ public boolean supportsIfExistsAfterTableName() {
+ return true;
+ }
public boolean supportsPooledSequences() {
@@ -226,75 +226,73 @@
return "drop sequence " + sequenceName;
}
- public String getSelectSequenceNextValString(String sequenceName) {
- return "next value for " + sequenceName;
- }
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "next value for " + sequenceName;
+ }
- public String getSequenceNextValString(String sequenceName) {
- return "call next value for " + sequenceName;
- }
+ public String getSequenceNextValString(String sequenceName) {
+ return "call next value for " + sequenceName;
+ }
- public String getQuerySequencesString() {
- return querySequenceString;
- }
+ public String getQuerySequencesString() {
+ return querySequenceString;
+ }
- public boolean supportsSequences() {
- return true;
- }
+ public boolean supportsSequences() {
+ return true;
+ }
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ String constraintName = null;
+ // 23000: Check constraint violation: {0}
+ // 23001: Unique index or primary key violation: {0}
+ if ( sqle.getSQLState().startsWith( "23" ) ) {
+ String message = sqle.getMessage();
+ int idx = message.indexOf( "violation: " );
+ if ( idx > 0 ) {
+ constraintName = message.substring( idx + "violation: ".length() );
+ }
+ }
+ return constraintName;
+ }
+ };
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- String constraintName = null;
- // 23000: Check constraint violation: {0}
- // 23001: Unique index or primary key violation: {0}
- if(sqle.getSQLState().startsWith("23")) {
- String message = sqle.getMessage();
- int idx = message.indexOf("violation: ");
- if(idx > 0) {
- constraintName = message.substring(idx + "violation: ".length());
- }
- }
- return constraintName;
- }
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
- };
+ public String getCreateTemporaryTableString() {
+ return "create temporary table if not exists";
+ }
- public boolean supportsTemporaryTables() {
- return true;
- }
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
- public String getCreateTemporaryTableString() {
- return "create temporary table if not exists";
- }
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
+ public String getCurrentTimestampSelectString() {
+ return "call current_timestamp()";
+ }
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
+ public boolean supportsUnionAll() {
+ return true;
+ }
- public String getCurrentTimestampSelectString() {
- return "call current_timestamp()";
- }
- public boolean supportsUnionAll() {
- return true;
- }
-
-
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean supportsLobValueChangePropogation() {
15 years, 7 months
Hibernate SVN: r16645 - core/branches/Branch_3_2/src/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-01 11:22:07 -0400 (Mon, 01 Jun 2009)
New Revision: 16645
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java
Log:
HHH-3401 - H2 Database Dialect Fixes
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:17:56 UTC (rev 16644)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/H2Dialect.java 2009-06-01 15:22:07 UTC (rev 16645)
@@ -15,32 +15,34 @@
/**
* A dialect compatible with the H2 database.
- *
+ *
* @author Thomas Mueller
- *
*/
public class H2Dialect extends Dialect {
private String querySequenceString;
+
public H2Dialect() {
super();
-
+
querySequenceString = "select sequence_name from information_schema.sequences";
- try {
- // HHH-2300
- Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
- Integer build = (Integer)constants.getDeclaredField("BUILD_ID" ).get(null);
- int buildid = build.intValue();
- if(buildid < 32) {
- querySequenceString = "select name from information_schema.sequences";
- }
- } catch(Throwable e) {
- // ignore (probably H2 not in the classpath)
- }
- registerColumnType(Types.BOOLEAN, "boolean");
+ try {
+ // HHH-2300
+ Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
+ Integer build = ( Integer ) constants.getDeclaredField( "BUILD_ID" ).get( null );
+ int buildid = build.intValue();
+ if ( buildid < 32 ) {
+ querySequenceString = "select name from information_schema.sequences";
+ }
+ }
+ catch ( Throwable e ) {
+ // ignore (probably H2 not in the classpath)
+ }
+
+ registerColumnType(Types.BOOLEAN, "boolean");
registerColumnType(Types.BIGINT, "bigint");
registerColumnType(Types.BINARY, "binary");
- registerColumnType(Types.BIT, "bit");
+ registerColumnType(Types.BIT, "boolean");
registerColumnType(Types.CHAR, "char($l)");
registerColumnType(Types.DATE, "date");
registerColumnType(Types.DECIMAL, "decimal($p,$s)");
@@ -49,7 +51,7 @@
registerColumnType(Types.INTEGER, "integer");
registerColumnType(Types.LONGVARBINARY, "longvarbinary");
registerColumnType(Types.LONGVARCHAR, "longvarchar");
- registerColumnType(Types.REAL, "real");
+ registerColumnType(Types.REAL, "real");
registerColumnType(Types.SMALLINT, "smallint");
registerColumnType(Types.TINYINT, "tinyint");
registerColumnType(Types.TIME, "time");
@@ -59,7 +61,7 @@
registerColumnType(Types.NUMERIC, "numeric");
registerColumnType(Types.BLOB, "blob");
registerColumnType(Types.CLOB, "clob");
-
+
// select topic, syntax from information_schema.help
// where section like 'Function%' order by section, topic
@@ -133,7 +135,7 @@
registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
- registerFunction("datediff", new NoArgSQLFunction("datediff", Hibernate.INTEGER));
+ registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER));
registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
@@ -142,7 +144,7 @@
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quater", new StandardSQLFunction("quater", Hibernate.INTEGER));
+ registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
@@ -192,15 +194,15 @@
}
public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer(sql.length() + 20).
- append(sql).
- append(hasOffset ? " limit ? offset ?" : " limit ?").
- toString();
+ return new StringBuffer(sql.length() + 20)
+ .append(sql)
+ .append(hasOffset ? " limit ? offset ?" : " limit ?")
+ .toString();
}
-
+
public boolean bindLimitParametersInReverseOrder() {
return true;
- }
+ }
public boolean bindLimitParametersFirst() {
return false;
@@ -271,7 +273,7 @@
public boolean supportsTemporaryTables() {
return true;
}
-
+
public String getCreateTemporaryTableString() {
return "create temporary table if not exists";
}
@@ -279,15 +281,15 @@
public boolean supportsCurrentTimestampSelection() {
return true;
}
-
+
public boolean isCurrentTimestampSelectStringCallable() {
return false;
}
-
+
public String getCurrentTimestampSelectString() {
return "call current_timestamp()";
- }
-
+ }
+
public boolean supportsUnionAll() {
return true;
}
@@ -298,4 +300,4 @@
public boolean supportsLobValueChangePropogation() {
return false;
}
-}
\ No newline at end of file
+}
15 years, 7 months