HHH-9948 - SequenceStyleGenerator uses potentially incorrect name for table/sequence in DML statements

This commit is contained in:
Steve Ebersole 2015-07-19 09:00:41 -05:00
parent 3584d59c9e
commit 855956135e
3 changed files with 20 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.model.relational.QualifiedName;
@ -81,6 +82,10 @@ public class SequenceStructure implements DatabaseStructure {
@Override
public AccessCallback buildCallback(final SessionImplementor session) {
if ( sql == null ) {
throw new AssertionFailure( "SequenceStyleGenerator's SequenceStructure was not properly initialized" );
}
return new AccessCallback() {
@Override
public IntegralDataTypeHolder getNextValue() {

View File

@ -12,6 +12,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.boot.model.naming.Identifier;
@ -112,6 +113,10 @@ public class TableStructure implements DatabaseStructure {
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
.getService( JdbcServices.class )
.getSqlStatementLogger();
if ( selectQuery == null || updateQuery == null ) {
throw new AssertionFailure( "SequenceStyleGenerator's TableStructure was not properly initialized" );
}
final SessionEventListenerManager statsCollector = session.getEventListenerManager();
return new AccessCallback() {

View File

@ -183,6 +183,8 @@ public class SimpleValue implements KeyValue {
}
}
private IdentifierGenerator identifierGenerator;
@Override
public IdentifierGenerator createIdentifierGenerator(
IdentifierGeneratorFactory identifierGeneratorFactory,
@ -190,7 +192,11 @@ public class SimpleValue implements KeyValue {
String defaultCatalog,
String defaultSchema,
RootClass rootClass) throws MappingException {
if ( identifierGenerator != null ) {
return identifierGenerator;
}
Properties params = new Properties();
//if the hibernate-mapping did not specify a schema/catalog, use the defaults
@ -250,7 +256,9 @@ public class SimpleValue implements KeyValue {
);
identifierGeneratorFactory.setDialect( dialect );
return identifierGeneratorFactory.createIdentifierGenerator( identifierGeneratorStrategy, getType(), params );
identifierGenerator = identifierGeneratorFactory.createIdentifierGenerator( identifierGeneratorStrategy, getType(), params );
return identifierGenerator;
}
public boolean isUpdateable() {