HHH-7927 Enabling globally_quoted_identifiers breaks schema validation
if TableGenerator is used
This commit is contained in:
parent
e1eef18d62
commit
dd44ad459a
|
@ -1342,6 +1342,9 @@ public class Configuration implements Serializable {
|
|||
while ( iter.hasNext() ) {
|
||||
PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
|
||||
Object key = generator.generatorKey();
|
||||
if (key instanceof String) {
|
||||
key = normalizer.normalizeIdentifierQuoting( (String) key );
|
||||
}
|
||||
if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
|
||||
throw new HibernateException( "Missing sequence or table: " + key );
|
||||
}
|
||||
|
|
|
@ -29,6 +29,12 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
@ -38,6 +44,8 @@ import org.hibernate.mapping.Table;
|
|||
import org.hibernate.mapping.UniqueKey;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -85,6 +93,20 @@ public class QuoteGlobalTest extends BaseCoreFunctionalTestCase {
|
|||
doTestHbmQuoting( DataPoint.class );
|
||||
doTestHbmQuoting( AssociatedDataPoint.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-7927")
|
||||
public void testTableGeneratorQuoting() {
|
||||
Configuration configuration = constructAndConfigureConfiguration();
|
||||
configuration.addAnnotatedClass(TestEntity.class);
|
||||
new SchemaExport(configuration).execute( false, true, false, true );
|
||||
try {
|
||||
new SchemaValidator(configuration).validate();
|
||||
}
|
||||
catch (HibernateException e) {
|
||||
fail( "The identifier generator table should have validated. " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestHbmQuoting(Class clazz) {
|
||||
Table table = configuration().getClassMapping( clazz.getName() ).getTable();
|
||||
|
@ -117,4 +139,11 @@ public class QuoteGlobalTest extends BaseCoreFunctionalTestCase {
|
|||
protected String[] getMappings() {
|
||||
return new String[] { "quote/DataPoint.hbm.xml" };
|
||||
}
|
||||
|
||||
@Entity
|
||||
private static class TestEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||
private int id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
|||
return cfg;
|
||||
}
|
||||
|
||||
private Configuration constructAndConfigureConfiguration() {
|
||||
protected Configuration constructAndConfigureConfiguration() {
|
||||
Configuration cfg = constructConfiguration();
|
||||
configure( cfg );
|
||||
return cfg;
|
||||
|
|
Loading…
Reference in New Issue