Hibernate SVN: r14044 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-10-02 22:50:59 -0400 (Tue, 02 Oct 2007)
New Revision: 14044
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java
Log:
HHH-2839 : HSQLDB and sequences
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 2007-10-03 02:25:50 UTC (rev 14043)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 2007-10-03 02:50:59 UTC (rev 14044)
@@ -202,31 +202,20 @@
return true;
}
- public String[] getCreateSequenceStrings(String sequenceName) {
- return getCreateSequenceStrings( sequenceName, 1, 1 );
+ protected String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
}
- public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) {
- return new String[] {
- "create table dual_" + sequenceName + " (zero integer)",
- "insert into dual_" + sequenceName + " values (0)",
- "create sequence " + sequenceName + " start with " + initialValue + " increment by " + incrementSize
- };
+ protected String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
}
- public String[] getDropSequenceStrings(String sequenceName) {
- return new String[] {
- "drop table dual_" + sequenceName + " if exists",
- "drop sequence " + sequenceName
- };
- }
-
public String getSelectSequenceNextValString(String sequenceName) {
return "next value for " + sequenceName;
}
public String getSequenceNextValString(String sequenceName) {
- return "select next value for " + sequenceName + " from dual_" + sequenceName;
+ return "call next value for " + sequenceName;
}
public String getQuerySequencesString() {
17 years, 2 months
Hibernate SVN: r14043 - core/trunk/core/src/main/java/org/hibernate/id.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-10-02 22:25:50 -0400 (Tue, 02 Oct 2007)
New Revision: 14043
Modified:
core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java
Log:
general code cleanup
Modified: core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:25:34 UTC (rev 14042)
+++ core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:25:50 UTC (rev 14043)
@@ -9,6 +9,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
@@ -21,111 +22,133 @@
* @author Gavin King
*/
public final class IdentifierGeneratorFactory {
-
- private static final Logger log = LoggerFactory.getLogger(IdentifierGeneratorFactory.class);
+ private static final Logger log = LoggerFactory.getLogger( IdentifierGeneratorFactory.class );
+
+ private static final HashMap GENERATORS = new HashMap();
+ static {
+ GENERATORS.put( "uuid", UUIDHexGenerator.class );
+ GENERATORS.put( "hilo", TableHiLoGenerator.class );
+ GENERATORS.put( "assigned", Assigned.class );
+ GENERATORS.put( "identity", IdentityGenerator.class );
+ GENERATORS.put( "select", SelectGenerator.class );
+ GENERATORS.put( "sequence", SequenceGenerator.class );
+ GENERATORS.put( "seqhilo", SequenceHiLoGenerator.class );
+ GENERATORS.put( "increment", IncrementGenerator.class );
+ GENERATORS.put( "foreign", ForeignGenerator.class );
+ GENERATORS.put( "guid", GUIDGenerator.class );
+ GENERATORS.put( "uuid.hex", UUIDHexGenerator.class ); // uuid.hex is deprecated
+ GENERATORS.put( "sequence-identity", SequenceIdentityGenerator.class );
+ }
+
+ public static final Serializable SHORT_CIRCUIT_INDICATOR = new Serializable() {
+ public String toString() {
+ return "SHORT_CIRCUIT_INDICATOR";
+ }
+ };
+
+ public static final Serializable POST_INSERT_INDICATOR = new Serializable() {
+ public String toString() {
+ return "POST_INSERT_INDICATOR";
+ }
+ };
+
/**
* Get the generated identifier when using identity columns
+ *
+ * @param rs The result set from which to extract the the generated identity.
+ * @param type The expected type mapping for the identity value.
+ * @return The generated identity value
+ * @throws SQLException Can be thrown while accessing the result set
+ * @throws HibernateException Indicates a problem reading back a generated identity value.
*/
- public static Serializable getGeneratedIdentity(ResultSet rs, Type type)
- throws SQLException, HibernateException, IdentifierGenerationException {
+ public static Serializable getGeneratedIdentity(ResultSet rs, Type type) throws SQLException, HibernateException {
if ( !rs.next() ) {
throw new HibernateException( "The database returned no natively generated identity value" );
}
final Serializable id = IdentifierGeneratorFactory.get( rs, type );
- if ( log.isDebugEnabled() ) log.debug( "Natively generated identity: " + id );
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Natively generated identity: " + id );
+ }
return id;
}
// unhappy about this being public ... is there a better way?
- public static Serializable get(ResultSet rs, Type type)
- throws SQLException, IdentifierGenerationException {
-
+ public static Serializable get(ResultSet rs, Type type) throws SQLException, IdentifierGenerationException {
Class clazz = type.getReturnedClass();
- if ( clazz==Long.class ) {
- return new Long( rs.getLong(1) );
+ if ( clazz == Long.class ) {
+ return new Long( rs.getLong( 1 ) );
}
- else if ( clazz==Integer.class ) {
- return new Integer( rs.getInt(1) );
+ else if ( clazz == Integer.class ) {
+ return new Integer( rs.getInt( 1 ) );
}
- else if ( clazz==Short.class ) {
- return new Short( rs.getShort(1) );
+ else if ( clazz == Short.class ) {
+ return new Short( rs.getShort( 1 ) );
}
- else if ( clazz==String.class ) {
- return rs.getString(1);
+ else if ( clazz == String.class ) {
+ return rs.getString( 1 );
}
else {
- throw new IdentifierGenerationException("this id generator generates long, integer, short or string");
+ throw new IdentifierGenerationException( "this id generator generates long, integer, short or string" );
}
-
- }
- private static final HashMap GENERATORS = new HashMap();
-
- public static final Serializable SHORT_CIRCUIT_INDICATOR = new Serializable() {
- public String toString() { return "SHORT_CIRCUIT_INDICATOR"; }
- };
-
- public static final Serializable POST_INSERT_INDICATOR = new Serializable() {
- public String toString() { return "POST_INSERT_INDICATOR"; }
- };
-
- static {
- GENERATORS.put("uuid", UUIDHexGenerator.class);
- GENERATORS.put("hilo", TableHiLoGenerator.class);
- GENERATORS.put("assigned", Assigned.class);
- GENERATORS.put("identity", IdentityGenerator.class);
- GENERATORS.put("select", SelectGenerator.class);
- GENERATORS.put("sequence", SequenceGenerator.class);
- GENERATORS.put("seqhilo", SequenceHiLoGenerator.class);
- GENERATORS.put("increment", IncrementGenerator.class);
- GENERATORS.put("foreign", ForeignGenerator.class);
- GENERATORS.put("guid", GUIDGenerator.class);
- GENERATORS.put("uuid.hex", UUIDHexGenerator.class); //uuid.hex is deprecated
- GENERATORS.put("sequence-identity", SequenceIdentityGenerator.class);
}
- public static IdentifierGenerator create(String strategy, Type type, Properties params, Dialect dialect)
- throws MappingException {
+ public static IdentifierGenerator create(String strategy, Type type, Properties params, Dialect dialect)
+ throws MappingException {
try {
Class clazz = getIdentifierGeneratorClass( strategy, dialect );
- IdentifierGenerator idgen = (IdentifierGenerator) clazz.newInstance();
- if (idgen instanceof Configurable) ( (Configurable) idgen).configure(type, params, dialect);
+ IdentifierGenerator idgen = ( IdentifierGenerator ) clazz.newInstance();
+ if ( idgen instanceof Configurable ) {
+ ( ( Configurable ) idgen ).configure( type, params, dialect );
+ }
return idgen;
}
- catch (Exception e) {
- throw new MappingException("could not instantiate id generator [entity-name=" + params.get( IdentifierGenerator.ENTITY_NAME ) + "]", e);
+ catch ( Exception e ) {
+ throw new MappingException(
+ "could not instantiate id generator [entity-name=" + params.get(
+ IdentifierGenerator.ENTITY_NAME
+ ) + "]", e
+ );
}
}
public static Class getIdentifierGeneratorClass(String strategy, Dialect dialect) {
- Class clazz = (Class) GENERATORS.get(strategy);
- if ( "native".equals(strategy) ) clazz = dialect.getNativeIdentifierGeneratorClass();
+ Class clazz = ( Class ) GENERATORS.get( strategy );
+ if ( "native".equals( strategy ) ) {
+ clazz = dialect.getNativeIdentifierGeneratorClass();
+ }
try {
- if (clazz==null) clazz = ReflectHelper.classForName(strategy);
+ if ( clazz == null ) {
+ clazz = ReflectHelper.classForName( strategy );
+ }
}
- catch (ClassNotFoundException e) {
- throw new MappingException("could not interpret id generator strategy: " + strategy);
+ catch ( ClassNotFoundException e ) {
+ throw new MappingException( "could not interpret id generator strategy: " + strategy );
}
return clazz;
}
public static Number createNumber(long value, Class clazz) throws IdentifierGenerationException {
- if ( clazz==Long.class ) {
- return new Long(value);
+ if ( clazz == Long.class ) {
+ return new Long( value );
}
- else if ( clazz==Integer.class ) {
- return new Integer( (int) value );
+ else if ( clazz == Integer.class ) {
+ return new Integer( ( int ) value );
}
- else if ( clazz==Short.class ) {
- return new Short( (short) value );
+ else if ( clazz == Short.class ) {
+ return new Short( ( short ) value );
}
else {
- throw new IdentifierGenerationException("this id generator generates long, integer, short");
+ throw new IdentifierGenerationException( "this id generator generates long, integer, short" );
}
}
- private IdentifierGeneratorFactory() {} //cannot be instantiated
+ /**
+ * Disallow instantiation.
+ */
+ private IdentifierGeneratorFactory() {
+ }
}
17 years, 2 months
Hibernate SVN: r14042 - core/branches/Branch_3_2/src/org/hibernate/id.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-10-02 22:25:34 -0400 (Tue, 02 Oct 2007)
New Revision: 14042
Modified:
core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java
Log:
general code cleanup
Modified: core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:12:41 UTC (rev 14041)
+++ core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:25:34 UTC (rev 14042)
@@ -9,6 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
@@ -21,111 +22,133 @@
* @author Gavin King
*/
public final class IdentifierGeneratorFactory {
-
- private static final Log log = LogFactory.getLog(IdentifierGeneratorFactory.class);
+ private static final Log log = LogFactory.getLog( IdentifierGeneratorFactory.class );
+
+ private static final HashMap GENERATORS = new HashMap();
+ static {
+ GENERATORS.put( "uuid", UUIDHexGenerator.class );
+ GENERATORS.put( "hilo", TableHiLoGenerator.class );
+ GENERATORS.put( "assigned", Assigned.class );
+ GENERATORS.put( "identity", IdentityGenerator.class );
+ GENERATORS.put( "select", SelectGenerator.class );
+ GENERATORS.put( "sequence", SequenceGenerator.class );
+ GENERATORS.put( "seqhilo", SequenceHiLoGenerator.class );
+ GENERATORS.put( "increment", IncrementGenerator.class );
+ GENERATORS.put( "foreign", ForeignGenerator.class );
+ GENERATORS.put( "guid", GUIDGenerator.class );
+ GENERATORS.put( "uuid.hex", UUIDHexGenerator.class ); // uuid.hex is deprecated
+ GENERATORS.put( "sequence-identity", SequenceIdentityGenerator.class );
+ }
+
+ public static final Serializable SHORT_CIRCUIT_INDICATOR = new Serializable() {
+ public String toString() {
+ return "SHORT_CIRCUIT_INDICATOR";
+ }
+ };
+
+ public static final Serializable POST_INSERT_INDICATOR = new Serializable() {
+ public String toString() {
+ return "POST_INSERT_INDICATOR";
+ }
+ };
+
/**
* Get the generated identifier when using identity columns
+ *
+ * @param rs The result set from which to extract the the generated identity.
+ * @param type The expected type mapping for the identity value.
+ * @return The generated identity value
+ * @throws SQLException Can be thrown while accessing the result set
+ * @throws HibernateException Indicates a problem reading back a generated identity value.
*/
- public static Serializable getGeneratedIdentity(ResultSet rs, Type type)
- throws SQLException, HibernateException, IdentifierGenerationException {
+ public static Serializable getGeneratedIdentity(ResultSet rs, Type type) throws SQLException, HibernateException {
if ( !rs.next() ) {
throw new HibernateException( "The database returned no natively generated identity value" );
}
final Serializable id = IdentifierGeneratorFactory.get( rs, type );
- if ( log.isDebugEnabled() ) log.debug( "Natively generated identity: " + id );
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Natively generated identity: " + id );
+ }
return id;
}
// unhappy about this being public ... is there a better way?
- public static Serializable get(ResultSet rs, Type type)
- throws SQLException, IdentifierGenerationException {
-
+ public static Serializable get(ResultSet rs, Type type) throws SQLException, IdentifierGenerationException {
Class clazz = type.getReturnedClass();
- if ( clazz==Long.class ) {
- return new Long( rs.getLong(1) );
+ if ( clazz == Long.class ) {
+ return new Long( rs.getLong( 1 ) );
}
- else if ( clazz==Integer.class ) {
- return new Integer( rs.getInt(1) );
+ else if ( clazz == Integer.class ) {
+ return new Integer( rs.getInt( 1 ) );
}
- else if ( clazz==Short.class ) {
- return new Short( rs.getShort(1) );
+ else if ( clazz == Short.class ) {
+ return new Short( rs.getShort( 1 ) );
}
- else if ( clazz==String.class ) {
- return rs.getString(1);
+ else if ( clazz == String.class ) {
+ return rs.getString( 1 );
}
else {
- throw new IdentifierGenerationException("this id generator generates long, integer, short or string");
+ throw new IdentifierGenerationException( "this id generator generates long, integer, short or string" );
}
-
- }
- private static final HashMap GENERATORS = new HashMap();
-
- public static final Serializable SHORT_CIRCUIT_INDICATOR = new Serializable() {
- public String toString() { return "SHORT_CIRCUIT_INDICATOR"; }
- };
-
- public static final Serializable POST_INSERT_INDICATOR = new Serializable() {
- public String toString() { return "POST_INSERT_INDICATOR"; }
- };
-
- static {
- GENERATORS.put("uuid", UUIDHexGenerator.class);
- GENERATORS.put("hilo", TableHiLoGenerator.class);
- GENERATORS.put("assigned", Assigned.class);
- GENERATORS.put("identity", IdentityGenerator.class);
- GENERATORS.put("select", SelectGenerator.class);
- GENERATORS.put("sequence", SequenceGenerator.class);
- GENERATORS.put("seqhilo", SequenceHiLoGenerator.class);
- GENERATORS.put("increment", IncrementGenerator.class);
- GENERATORS.put("foreign", ForeignGenerator.class);
- GENERATORS.put("guid", GUIDGenerator.class);
- GENERATORS.put("uuid.hex", UUIDHexGenerator.class); //uuid.hex is deprecated
- GENERATORS.put("sequence-identity", SequenceIdentityGenerator.class);
}
- public static IdentifierGenerator create(String strategy, Type type, Properties params, Dialect dialect)
- throws MappingException {
+ public static IdentifierGenerator create(String strategy, Type type, Properties params, Dialect dialect)
+ throws MappingException {
try {
Class clazz = getIdentifierGeneratorClass( strategy, dialect );
- IdentifierGenerator idgen = (IdentifierGenerator) clazz.newInstance();
- if (idgen instanceof Configurable) ( (Configurable) idgen).configure(type, params, dialect);
+ IdentifierGenerator idgen = ( IdentifierGenerator ) clazz.newInstance();
+ if ( idgen instanceof Configurable ) {
+ ( ( Configurable ) idgen ).configure( type, params, dialect );
+ }
return idgen;
}
- catch (Exception e) {
- throw new MappingException("could not instantiate id generator [entity-name=" + params.get( IdentifierGenerator.ENTITY_NAME ) + "]", e);
+ catch ( Exception e ) {
+ throw new MappingException(
+ "could not instantiate id generator [entity-name=" + params.get(
+ IdentifierGenerator.ENTITY_NAME
+ ) + "]", e
+ );
}
}
public static Class getIdentifierGeneratorClass(String strategy, Dialect dialect) {
- Class clazz = (Class) GENERATORS.get(strategy);
- if ( "native".equals(strategy) ) clazz = dialect.getNativeIdentifierGeneratorClass();
+ Class clazz = ( Class ) GENERATORS.get( strategy );
+ if ( "native".equals( strategy ) ) {
+ clazz = dialect.getNativeIdentifierGeneratorClass();
+ }
try {
- if (clazz==null) clazz = ReflectHelper.classForName(strategy);
+ if ( clazz == null ) {
+ clazz = ReflectHelper.classForName( strategy );
+ }
}
- catch (ClassNotFoundException e) {
- throw new MappingException("could not interpret id generator strategy: " + strategy);
+ catch ( ClassNotFoundException e ) {
+ throw new MappingException( "could not interpret id generator strategy: " + strategy );
}
return clazz;
}
public static Number createNumber(long value, Class clazz) throws IdentifierGenerationException {
- if ( clazz==Long.class ) {
- return new Long(value);
+ if ( clazz == Long.class ) {
+ return new Long( value );
}
- else if ( clazz==Integer.class ) {
- return new Integer( (int) value );
+ else if ( clazz == Integer.class ) {
+ return new Integer( ( int ) value );
}
- else if ( clazz==Short.class ) {
- return new Short( (short) value );
+ else if ( clazz == Short.class ) {
+ return new Short( ( short ) value );
}
else {
- throw new IdentifierGenerationException("this id generator generates long, integer, short");
+ throw new IdentifierGenerationException( "this id generator generates long, integer, short" );
}
}
- private IdentifierGeneratorFactory() {} //cannot be instantiated
+ /**
+ * Disallow instantiation.
+ */
+ private IdentifierGeneratorFactory() {
+ }
}
17 years, 2 months
Hibernate SVN: r14041 - core/trunk/core/src/main/java/org/hibernate/id.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-10-02 22:12:41 -0400 (Tue, 02 Oct 2007)
New Revision: 14041
Modified:
core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java
Log:
HHH-2849 : IdentifierGeneratorFactory error logging
Modified: core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:12:20 UTC (rev 14040)
+++ core/trunk/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:12:41 UTC (rev 14041)
@@ -95,7 +95,7 @@
return idgen;
}
catch (Exception e) {
- throw new MappingException("could not instantiate id generator", e);
+ throw new MappingException("could not instantiate id generator [entity-name=" + params.get( IdentifierGenerator.ENTITY_NAME ) + "]", e);
}
}
17 years, 2 months
Hibernate SVN: r14040 - core/branches/Branch_3_2/src/org/hibernate/id.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-10-02 22:12:20 -0400 (Tue, 02 Oct 2007)
New Revision: 14040
Modified:
core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java
Log:
HHH-2849 : IdentifierGeneratorFactory error logging
Modified: core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-02 21:35:29 UTC (rev 14039)
+++ core/branches/Branch_3_2/src/org/hibernate/id/IdentifierGeneratorFactory.java 2007-10-03 02:12:20 UTC (rev 14040)
@@ -95,7 +95,7 @@
return idgen;
}
catch (Exception e) {
- throw new MappingException("could not instantiate id generator", e);
+ throw new MappingException("could not instantiate id generator [entity-name=" + params.get( IdentifierGenerator.ENTITY_NAME ) + "]", e);
}
}
17 years, 2 months
Hibernate SVN: r14039 - core/branches/Branch_3_2/etc.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2007-10-02 17:35:29 -0400 (Tue, 02 Oct 2007)
New Revision: 14039
Modified:
core/branches/Branch_3_2/etc/log4j.properties
Log:
changed log4j.logger.org.hibernate from debug to info
Modified: core/branches/Branch_3_2/etc/log4j.properties
===================================================================
--- core/branches/Branch_3_2/etc/log4j.properties 2007-10-02 18:59:20 UTC (rev 14038)
+++ core/branches/Branch_3_2/etc/log4j.properties 2007-10-02 21:35:29 UTC (rev 14039)
@@ -14,8 +14,8 @@
log4j.rootLogger=warn, stdout
-#log4j.logger.org.hibernate=info
-log4j.logger.org.hibernate=debug
+log4j.logger.org.hibernate=info
+#log4j.logger.org.hibernate=debug
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
17 years, 2 months
Hibernate SVN: r14038 - jpa-api/trunk/src/javax/persistence.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-10-02 14:59:20 -0400 (Tue, 02 Oct 2007)
New Revision: 14038
Modified:
jpa-api/trunk/src/javax/persistence/Persistence.java
Log:
EJB-316 add final modifier for TCK sig tests
Modified: jpa-api/trunk/src/javax/persistence/Persistence.java
===================================================================
--- jpa-api/trunk/src/javax/persistence/Persistence.java 2007-09-29 19:38:53 UTC (rev 14037)
+++ jpa-api/trunk/src/javax/persistence/Persistence.java 2007-10-02 18:59:20 UTC (rev 14038)
@@ -19,7 +19,7 @@
*/
public class Persistence {
- public static String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
+ public static final String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();
protected static final Set<PersistenceProvider> providers = new HashSet<PersistenceProvider>();
17 years, 2 months