HHH-7927 Enabling globally_quoted_identifiers breaks schema validation

if TableGenerator is used
Conflicts:
	hibernate-core/src/test/java/org/hibernate/test/quote/QuoteGlobalTest.java
This commit is contained in:
Brett Meyer 2013-10-31 07:04:52 -04:00
parent c38533c4ae
commit 350171c8ba
3 changed files with 33 additions and 1 deletions

View File

@ -1312,6 +1312,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 );
}

View File

@ -28,6 +28,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;
@ -35,6 +41,8 @@ import org.hibernate.cfg.Environment;
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;
/**
@ -76,6 +84,20 @@ public class QuoteGlobalTest extends BaseCoreFunctionalTestCase {
s.close();
}
@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() );
}
}
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
@ -92,4 +114,11 @@ public class QuoteGlobalTest extends BaseCoreFunctionalTestCase {
House.class
};
}
@Entity
private static class TestEntity {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private int id;
}
}

View File

@ -161,7 +161,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
return cfg;
}
private Configuration constructAndConfigureConfiguration() {
protected Configuration constructAndConfigureConfiguration() {
Configuration cfg = constructConfiguration();
configure( cfg );
return cfg;