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 72bdaf529b..45fc6acf84 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 @@ import javax.persistence.Table; @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 9c7c4ab727..88baf016ad 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 java.util.List; 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 class NamedNativeQueryTest extends BaseCoreFunctionalTestCase { 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 class NamedNativeQueryTest extends BaseCoreFunctionalTestCase { 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 class NamedNativeQueryTest extends BaseCoreFunctionalTestCase { } @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";