HHH-12555 Add a DialectCheck for NClob support

This commit is contained in:
Guillaume Smet 2018-12-17 13:53:54 +01:00
parent 4d0b5dc184
commit 855f34c771
2 changed files with 25 additions and 17 deletions

View File

@ -6,6 +6,11 @@
*/
package org.hibernate.test.nationalized;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.fail;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
@ -15,30 +20,18 @@ import org.hibernate.Session;
import org.hibernate.annotations.Nationalized;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.resource.transaction.spi.TransactionStatus;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.fail;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* @author Andrea Boriero
*/
@TestForIssue(jiraKey = "HHH-10364")
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support getNClob")
@SkipForDialect(value = MySQLDialect.class, comment = "MySQL/MariadB doesn't support nclob")
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL doesn't support nclob")
@SkipForDialect(value = SybaseDialect.class, comment = "Sybase doesn't support nclob")
@RequiresDialectFeature(DialectChecks.SupportsNClob.class)
public class NationalizedLobFieldTest extends BaseCoreFunctionalTestCase {
@Override

View File

@ -8,6 +8,9 @@ package org.hibernate.testing;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SybaseDialect;
/**
* Container class for different implementation of the {@link DialectCheck} interface.
@ -256,4 +259,16 @@ abstract public class DialectChecks {
);
}
}
public static class SupportsNClob implements DialectCheck {
@Override
public boolean isMatch(Dialect dialect) {
return !(
dialect instanceof DB2Dialect ||
dialect instanceof PostgreSQL81Dialect ||
dialect instanceof SybaseDialect ||
dialect instanceof MySQLDialect
);
}
}
}