HHH-4412 Corrected multiple test issues found in matrix CI

This commit is contained in:
Brett Meyer 2013-03-11 15:40:51 -04:00
parent b6d740d6d2
commit 3815080207
2 changed files with 15 additions and 6 deletions

View File

@ -37,12 +37,12 @@ import javax.persistence.Table;
@Table(name = "destination_entity") @Table(name = "destination_entity")
@NamedNativeQueries({ @NamedNativeQueries({
@NamedNativeQuery(name = "DestinationEntity.insertSelect", query = "insert into destination_entity(id, from_id, fullNameFrom) " @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) " @NamedNativeQuery(name = "DestinationEntity.insert", query = "insert into destination_entity(id, from_id, fullNameFrom) "
+ "values (:generatedId, :fromId, :fullName)"), + "values (:generatedId, :fromId, :fullName)"),
@NamedNativeQuery(name = "DestinationEntity.update", query = "update destination_entity set from_id=:idFrom, fullNameFrom=:fullName" @NamedNativeQuery(name = "DestinationEntity.update", query = "update destination_entity set from_id=:idFrom, fullNameFrom=:fullName"
+ " where id in (:ids)"), + " 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)") }) @NamedNativeQuery(name = "DestinationEntity.selectIds", query = "select id, from_id, fullNameFrom from destination_entity where id in (:ids)") })
public class DestinationEntity { public class DestinationEntity {

View File

@ -30,6 +30,8 @@ import java.util.List;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -82,8 +84,10 @@ public class NamedNativeQueryTest extends BaseCoreFunctionalTestCase {
Object[] unique = (Object[]) select.uniqueResult(); Object[] unique = (Object[]) select.uniqueResult();
session.close(); session.close();
assertEquals( destination.id, unique[0] ); // Compare the Strings, not the actual IDs. Can come back as, for ex,
assertEquals( destination.from.id, unique[1] ); // a BigDecimal in Oracle.
assertEquals( destination.id + "", unique[0] + "" );
assertEquals( destination.from.id + "", unique[1] + "" );
assertEquals( destination.fullNameFrom, unique[2] ); assertEquals( destination.fullNameFrom, unique[2] );
} }
@ -111,8 +115,10 @@ public class NamedNativeQueryTest extends BaseCoreFunctionalTestCase {
for ( int i = 0; i < list.size(); i++ ) { for ( int i = 0; i < list.size(); i++ ) {
Object[] object = (Object[]) list.get( i ); Object[] object = (Object[]) list.get( i );
DestinationEntity destination = destinations.get( i ); DestinationEntity destination = destinations.get( i );
assertEquals( destination.id, object[0] ); // Compare the Strings, not the actual IDs. Can come back as, for ex,
assertEquals( destination.from.id, object[1] ); // a BigDecimal in Oracle.
assertEquals( destination.id + "", object[0] + "" );
assertEquals( destination.from.id + "", object[1] + "" );
assertEquals( destination.fullNameFrom, object[2] ); assertEquals( destination.fullNameFrom, object[2] );
} }
} }
@ -145,6 +151,9 @@ public class NamedNativeQueryTest extends BaseCoreFunctionalTestCase {
} }
@Test @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() { public void testInsertMultipleValues() {
final String name = "Name"; final String name = "Name";
final String lastName = "LastName"; final String lastName = "LastName";