Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not quote catalog when add it to mapping #20

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ public Iterator iterateTables() {
}

public Table addTable(String schema, String catalog, String name) {
return mappings.addTable(quote(schema), quote(catalog), quote(name), null, false);
//pass catalog as it is as Table#setCatalog(catalog) doesn't do unquote
return mappings.addTable(quote(schema), catalog, quote(name), null, false);
}

public Table getTable(String schema, String catalog, String name) {
return mappings.getTable(quote(schema), quote(catalog), quote(name));
return mappings.getTable(quote(schema), catalog, quote(name));
}

}
6 changes: 6 additions & 0 deletions src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected void assertEqualIdentifiers(String expected, String actual) {
*/
protected void executeDDL(String[] sqls, boolean ignoreErrors) throws SQLException {
Configuration configuration = new Configuration();
configure(configuration);
Settings testSettings = configuration.buildSettings();

if(!appliesTo( testSettings.getDialect() )) {
Expand Down Expand Up @@ -151,6 +152,11 @@ protected void tearDown() throws Exception {
/**
* @param cfg2
*/
protected void configure(Configuration configuration) {


}

protected void configure(JDBCMetaDataConfiguration configuration) {


Expand Down
63 changes: 63 additions & 0 deletions src/test/org/hibernate/tool/hbm2x/H2SpecialSymbolsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Created on 27.03.2012
*/
package org.hibernate.tool.hbm2x;

import java.sql.SQLException;

import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.JDBCMetaDataConfiguration;
import org.hibernate.dialect.Dialect;
import org.hibernate.tool.JDBCMetaDataBinderTestCase;
import org.hibernate.tool.test.TestHelper;

/**
* @author Dmitry Geraskov (geraskov@gmail.com)
*
*/
public class H2SpecialSymbolsTest extends JDBCMetaDataBinderTestCase {

private static final String SCHEMA = "\"TEST2.DOT\"";
private static final String TABLE = "\"TEST3.DOT\"";

protected String[] getCreateSQL() {
return new String[]{
"create schema " + SCHEMA,
"create table " + SCHEMA +'.' + TABLE +" (ID integer not null unique, NAME varchar(255), primary key (ID), unique (ID));",
};
}

protected String[] getDropSQL() {
return new String[]{
"drop table " + SCHEMA + '.' + TABLE,
"drop schema " + SCHEMA

};
}

protected void configure(Configuration configuration) {
configuration.setProperty("hibernate.connection.url", "jdbc:h2:testdb/test.dot;LOCK_MODE=0;TRACE_LEVEL_SYSTEM_OUT=2");
}

protected void configure(JDBCMetaDataConfiguration configuration) {
configure((Configuration)configuration);
}

public void testGenerateJava() throws SQLException, ClassNotFoundException {
ArtifactCollector collector = new ArtifactCollector();
POJOExporter exporter = new POJOExporter(cfg,getOutputDir());
exporter.setArtifactCollector(collector);
exporter.getProperties().setProperty("ejb3", "true");
exporter.start();

assertTrue("Can't read tables", cfg.getTableMappings().hasNext());
assertTrue("Nothing is generated", collector.getFileCount("java") > 0);

TestHelper.deleteDir(getOutputDir());
}

public boolean appliesTo(Dialect dialect) {
return dialect instanceof org.hibernate.dialect.H2Dialect;
}

}
2 changes: 1 addition & 1 deletion src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Test suite() {
suite.addTestSuite(GenericExporterTest.class);
suite.addTestSuite(Hbm2JavaTest.class);
//$JUnit-END$

suite.addTestSuite(H2SpecialSymbolsTest.class);
suite.addTestSuite(H2IdentityTest.class);
suite.addTestSuite(MySQLIdentityTest.class);
suite.addTestSuite(HSQLIdentityTest.class);
Expand Down