HHH-7346 Tests fail on Postgresql due to failure in typecasts

This commit is contained in:
Strong Liu 2012-05-23 21:28:57 +08:00
parent 1f467c01a4
commit d92e91bb4d
19 changed files with 47 additions and 28 deletions

View File

@ -22,7 +22,7 @@
# Boston, MA 02110-1301 USA
#
hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
hibernate.dialect org.hibernate.dialect.PostgreSQL82Dialect
hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql://localhost/hibernate
hibernate.connection.username hibernate

View File

@ -343,9 +343,13 @@
<entry>org.hibernate.dialect.PointbaseDialect</entry>
</row>
<row>
<entry>PostgreSQL</entry>
<entry>org.hibernate.dialect.PostgreSQLDialect</entry>
<entry>PostgreSQL 8.1</entry>
<entry>org.hibernate.dialect.PostgreSQL81Dialect</entry>
</row>
<row>
<entry>PostgreSQL 8.2 and later</entry>
<entry>org.hibernate.dialect.PostgreSQL82Dialect</entry>
</row>
<row>
<entry>Progress</entry>
<entry>org.hibernate.dialect.ProgressDialect</entry>

View File

@ -6,4 +6,4 @@ hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect

View File

@ -206,7 +206,7 @@ hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
<para>For use inside an application server, you should almost always
configure Hibernate to obtain connections from an application server
@ -275,7 +275,7 @@ hibernate.transaction.factory_class = \
org.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class = \
org.hibernate.transaction.JBossTransactionManagerLookup
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect</programlisting>
<para>JDBC connections obtained from a JNDI datasource will automatically
participate in the container-managed transactions of the application
@ -975,11 +975,15 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
</row>
<row>
<entry>PostgreSQL</entry>
<entry>PostgreSQL 8.1</entry>
<entry><literal>org.hibernate.dialect.PostgreSQLDialect</literal></entry>
<entry><literal>org.hibernate.dialect.PostgreSQL81Dialect</literal></entry>
</row>
<row>
<entry>PostgreSQL 8.2 and later</entry>
<entry><literal>org.hibernate.dialect.PostgreSQL82Dialect</literal></entry>
</row>
<row>
<entry>MySQL5</entry>
@ -1023,11 +1027,16 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
</row>
<row>
<entry>Sybase</entry>
<entry>Sybase ASE 15.5</entry>
<entry><literal>org.hibernate.dialect.SybaseASE15Dialect</literal></entry>
</row>
<row>
<entry>Sybase ASE 15.7</entry>
<entry><literal>org.hibernate.dialect.SybaseASE157Dialect</literal></entry>
</row>
<row>
<entry>Sybase Anywhere</entry>

View File

@ -27,6 +27,7 @@ package org.hibernate.criterion;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.engine.spi.TypedValue;
@ -57,7 +58,7 @@ public class IlikeExpression implements Criterion {
if ( columns.length != 1 ) {
throw new HibernateException( "ilike may only be used with single-column properties" );
}
if ( dialect instanceof PostgreSQLDialect ) {
if ( dialect instanceof PostgreSQLDialect || dialect instanceof PostgreSQL81Dialect) {
return columns[0] + " ilike ?";
}
else {

View File

@ -354,7 +354,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
}
@Test
@SkipForDialect(value = { PostgreSQL81Dialect.class },
@SkipForDialect(value = { PostgreSQL81Dialect.class, PostgreSQLDialect.class },
comment = "postgresql jdbc driver does not implement the setQueryTimeout method")
public void testCache() throws Exception {
Session s;

View File

@ -45,7 +45,7 @@ import static org.junit.Assert.assertNotNull;
*/
public class Ejb3XmlTest extends BaseCoreFunctionalTestCase {
@Test
@SkipForDialect(value = { PostgreSQL81Dialect.class },
@SkipForDialect(value = { PostgreSQL81Dialect.class, PostgreSQLDialect.class },
comment = "postgresql jdbc driver does not implement the setQueryTimeout method")
public void testEjb3Xml() throws Exception {
Session s = openSession();

View File

@ -49,7 +49,7 @@ public class AuctionTest extends BaseCoreFunctionalTestCase {
@Test
@SuppressWarnings( {"unchecked"})
@SkipForDialect( value = PostgreSQL81Dialect.class, comment = "doesn't like boolean=1" )
@SkipForDialect( value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class}, comment = "doesn't like boolean=1" )
public void testLazy() {
Session s = openSession();
Transaction t = s.beginTransaction();

View File

@ -30,6 +30,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -67,7 +68,7 @@ public class LikeTest extends BaseCoreFunctionalTestCase {
assertEquals( 1, objects.size() );
session.clear();
if ( !( getDialect() instanceof MySQLDialect ) && ! ( getDialect() instanceof PostgreSQLDialect )) {
if ( !( getDialect() instanceof MySQLDialect ) && ! ( getDialect() instanceof PostgreSQLDialect ) && ! ( getDialect() instanceof PostgreSQL81Dialect )) {
// retrieve object - case insensitive via custom expression - works
// ok
objects = session.createCriteria( TestObject.class ).add(

View File

@ -28,6 +28,7 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -65,7 +66,7 @@ public class FormulaJoinTest extends BaseCoreFunctionalTestCase {
tx.commit();
s.close();
if ( getDialect() instanceof PostgreSQLDialect ) return;
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) return;
s = openSession();
tx = s.beginTransaction();

View File

@ -53,6 +53,7 @@ import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServer2008Dialect;
import org.hibernate.dialect.SQLServerDialect;
@ -451,7 +452,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
else {
s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setString( "bar", "xyz" ).list();
}
if ( ! ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof MySQLDialect ) ) {
if ( ! ( getDialect() instanceof PostgreSQLDialect|| getDialect() instanceof PostgreSQL81Dialect || getDialect() instanceof MySQLDialect ) ) {
s.createQuery( "from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0" ).setLong( "param", 1 ).list();
}
s.getTransaction().commit();
@ -2751,7 +2752,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
* PostgreSQL >= 8.3.7 typecasts are no longer automatically allowed
* <link>http://www.postgresql.org/docs/current/static/release-8-3.html</link>
*/
if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof HSQLDialect){
if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect || getDialect() instanceof HSQLDialect){
hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24";
}
else{
@ -2759,7 +2760,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
}
session.createQuery(hql).list();
if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof HSQLDialect){
if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect || getDialect() instanceof HSQLDialect){
hql = "select bit_length(str(a.bodyWeight)) from Animal a";
}else{
hql = "select bit_length(a.bodyWeight) from Animal a";

View File

@ -41,6 +41,7 @@ import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.Sybase11Dialect;
@ -354,7 +355,7 @@ public class HQLTest extends QueryTranslatorTestCase {
if ( !( getDialect() instanceof MySQLDialect ) && ! ( getDialect() instanceof SybaseDialect ) && ! ( getDialect() instanceof Sybase11Dialect ) && !( getDialect() instanceof SybaseASE15Dialect ) && ! ( getDialect() instanceof SybaseAnywhereDialect ) && ! ( getDialect() instanceof SQLServerDialect ) ) {
assertTranslation("from Animal where lower(upper('foo') || upper(:bar)) like 'f%'");
}
if ( getDialect() instanceof PostgreSQLDialect ) {
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) {
return;
}
assertTranslation("from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0");
@ -838,7 +839,7 @@ public class HQLTest extends QueryTranslatorTestCase {
@Test
public void testGroupByFunction() {
if ( getDialect() instanceof Oracle8iDialect ) return; // the new hiearchy...
if ( getDialect() instanceof PostgreSQLDialect ) return;
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) return;
if ( ! H2Dialect.class.isInstance( getDialect() ) ) {
// H2 has no year function
assertTranslation( "select count(*) from Human h group by year(h.birthdate)" );

View File

@ -34,7 +34,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Pawel Stawicki
*/
@RequiresDialect( value = PostgreSQL81Dialect.class, jiraKey = "HHH-6580" )
@RequiresDialect( value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class}, jiraKey = "HHH-6580" )
public class PersistChildEntitiesWithDiscriminatorTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {

View File

@ -40,7 +40,7 @@ public class CustomSQLTest extends LegacyTestCase {
@Test
@RequiresDialectFeature( NonIdentityGeneratorChecker.class )
@SkipForDialect( value = PostgreSQL81Dialect.class, jiraKey = "HHH-6704")
@SkipForDialect( value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class}, jiraKey = "HHH-6704")
@SuppressWarnings( {"UnnecessaryBoxing"})
public void testInsert() throws HibernateException, SQLException {
Session s = openSession();

View File

@ -71,6 +71,7 @@ import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SAPDBDialect;
import org.hibernate.dialect.Sybase11Dialect;
@ -2293,7 +2294,7 @@ public class FooBarTest extends LegacyTestCase {
s.createQuery( "select count(*) from Baz as baz where 1 in indices(baz.fooArray)" ).list();
s.createQuery( "select count(*) from Bar as bar where 'abc' in elements(bar.baz.fooArray)" ).list();
s.createQuery( "select count(*) from Bar as bar where 1 in indices(bar.baz.fooArray)" ).list();
if ( !(getDialect() instanceof DB2Dialect) && !(getDialect() instanceof Oracle8iDialect ) && !( getDialect() instanceof SybaseDialect ) && !( getDialect() instanceof Sybase11Dialect ) && !( getDialect() instanceof SybaseASE15Dialect ) && !( getDialect() instanceof PostgreSQLDialect )) {
if ( !(getDialect() instanceof DB2Dialect) && !(getDialect() instanceof Oracle8iDialect ) && !( getDialect() instanceof SybaseDialect ) && !( getDialect() instanceof Sybase11Dialect ) && !( getDialect() instanceof SybaseASE15Dialect ) && !( getDialect() instanceof PostgreSQLDialect ) && !(getDialect() instanceof PostgreSQL81Dialect)) {
// SybaseAnywhereDialect supports implicit conversions from strings to ints
s.createQuery(
"select count(*) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)"
@ -2368,7 +2369,7 @@ public class FooBarTest extends LegacyTestCase {
s.delete(bar);
if ( getDialect() instanceof DB2Dialect || getDialect() instanceof PostgreSQLDialect ) {
if ( getDialect() instanceof DB2Dialect || getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) {
s.createQuery( "select one from One one join one.manies many group by one order by count(many)" ).iterate();
s.createQuery( "select one from One one join one.manies many group by one having count(many) < 5" )
.iterate();

View File

@ -57,7 +57,7 @@ public abstract class LegacyTestCase extends BaseCoreFunctionalTestCase {
protected boolean supportsLockingNullableSideOfJoin(Dialect dialect) {
// db2 and pgsql do *NOT*
return ! ( DB2Dialect.class.isInstance( dialect ) || PostgreSQL81Dialect.class.isInstance( dialect ) );
return ! ( DB2Dialect.class.isInstance( dialect ) || PostgreSQL81Dialect.class.isInstance( dialect ) || PostgreSQLDialect.class.isInstance( dialect ));
}
protected static String extractFromSystem(String systemPropertyName) {

View File

@ -374,7 +374,7 @@ public class SQLLoaderTest extends LegacyTestCase {
}
@Test
@SkipForDialect( { HSQLDialect.class, PostgreSQL81Dialect.class } )
@SkipForDialect( { HSQLDialect.class, PostgreSQL81Dialect.class, PostgreSQLDialect.class } )
public void testEscapedJDBC() throws HibernateException, SQLException {
Session session = openSession();
session.beginTransaction();

View File

@ -43,7 +43,7 @@ import static org.junit.Assert.assertNotSame;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@TestForIssue(jiraKey = "HHH-6780")
@SkipForDialect( value = PostgreSQL81Dialect.class, comment = "PostgreSQL jdbc driver doesn't impl timeout method")
@SkipForDialect( value ={ PostgreSQL81Dialect.class, PostgreSQLDialect.class}, comment = "PostgreSQL jdbc driver doesn't impl timeout method")
public class TransactionTimeoutTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -70,7 +70,7 @@ public class TypeOverrideTest extends BaseCoreFunctionalTestCase {
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT )
);
}
else if ( PostgreSQL81Dialect.class.isInstance( getDialect() ) ) {
else if ( PostgreSQL81Dialect.class.isInstance( getDialect() ) || PostgreSQLDialect.class.isInstance( getDialect() ) ) {
assertSame(
BlobTypeDescriptor.BLOB_BINDING,
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT )