From 2d1596086e8d81462039c92c1cf2a60c36e8d02a Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Mon, 11 Mar 2013 15:40:51 -0400 Subject: [PATCH] HHH-4412 Corrected multiple test issues found in matrix CI --- .../test/jpa/ql/DestinationEntity.java | 4 ++-- .../test/jpa/ql/NamedNativeQueryTest.java | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java index 72bdaf529bda..45fc6acf84b6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java @@ -37,12 +37,12 @@ @Table(name = "destination_entity") @NamedNativeQueries({ @NamedNativeQuery(name = "DestinationEntity.insertSelect", query = "insert into destination_entity(id, from_id, fullNameFrom) " - + " select fe.id, fe.id, fe.name||fe.lastName from from_entity fe where fe.id in (:ids)"), + + " select fe.id, fe.id, concat(fe.name, fe.lastName) from from_entity fe where fe.id in (:ids)"), @NamedNativeQuery(name = "DestinationEntity.insert", query = "insert into destination_entity(id, from_id, fullNameFrom) " + "values (:generatedId, :fromId, :fullName)"), @NamedNativeQuery(name = "DestinationEntity.update", query = "update destination_entity set from_id=:idFrom, fullNameFrom=:fullName" + " where id in (:ids)"), - @NamedNativeQuery(name = "DestinationEntity.delete", query = "delete destination_entity where id in (:ids)"), + @NamedNativeQuery(name = "DestinationEntity.delete", query = "delete from destination_entity where id in (:ids)"), @NamedNativeQuery(name = "DestinationEntity.selectIds", query = "select id, from_id, fullNameFrom from destination_entity where id in (:ids)") }) public class DestinationEntity { diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java index 9c7c4ab72781..88baf016adda 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java @@ -30,6 +30,8 @@ import org.hibernate.Query; import org.hibernate.Session; +import org.hibernate.dialect.MySQLDialect; +import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -82,8 +84,10 @@ public void testSingleSelect() { Object[] unique = (Object[]) select.uniqueResult(); session.close(); - assertEquals( destination.id, unique[0] ); - assertEquals( destination.from.id, unique[1] ); + // Compare the Strings, not the actual IDs. Can come back as, for ex, + // a BigDecimal in Oracle. + assertEquals( destination.id + "", unique[0] + "" ); + assertEquals( destination.from.id + "", unique[1] + "" ); assertEquals( destination.fullNameFrom, unique[2] ); } @@ -111,8 +115,10 @@ public void testMultipleSelect() { for ( int i = 0; i < list.size(); i++ ) { Object[] object = (Object[]) list.get( i ); DestinationEntity destination = destinations.get( i ); - assertEquals( destination.id, object[0] ); - assertEquals( destination.from.id, object[1] ); + // Compare the Strings, not the actual IDs. Can come back as, for ex, + // a BigDecimal in Oracle. + assertEquals( destination.id + "", object[0] + "" ); + assertEquals( destination.from.id + "", object[1] + "" ); assertEquals( destination.fullNameFrom, object[2] ); } } @@ -145,6 +151,9 @@ public void testInsertSingleValue() { } @Test + @SkipForDialect( value = MySQLDialect.class, + comment = "MySQL appears to have trouble with fe.id selected twice in one statement") + // TODO: Re-form DestinationEntity.insertSelect to something more supported? public void testInsertMultipleValues() { final String name = "Name"; final String lastName = "LastName";