HHH-12098 - prep 5.3

This commit is contained in:
Steve Ebersole 2017-12-01 15:08:47 -06:00
parent e960f17a7b
commit 888ade0106
5 changed files with 38 additions and 46 deletions

View File

@ -904,37 +904,19 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
@Test
public void testUpdateOnImplicitJoinFails() {
Session s = openSession();
Transaction t = s.beginTransaction();
Human human = new Human();
human.setName( new Name( "Steve", 'E', null ) );
Human mother = new Human();
mother.setName( new Name( "Jane", 'E', null ) );
human.setMother( mother );
s.save( human );
s.save( mother );
s.flush();
t.commit();
t = s.beginTransaction();
try {
s.createQuery( "update Human set mother.name.initial = :initial" ).setString( "initial", "F" ).executeUpdate();
fail( "update allowed across implicit join" );
}
catch (IllegalArgumentException e) {
assertTyping( QueryException.class, e.getCause() );
}
catch( QueryException e ) {
}
s.createQuery( "delete Human where mother is not null" ).executeUpdate();
s.createQuery( "delete Human" ).executeUpdate();
t.commit();
s.close();
inTransaction(
s -> {
try {
s.createQuery( "update Human set mother.name.initial = :initial" ).setString( "initial", "F" ).executeUpdate();
fail( "update allowed across implicit join" );
}
catch (IllegalArgumentException e) {
assertTyping( QueryException.class, e.getCause() );
}
catch( QueryException e ) {
}
}
);
}
@Test

View File

@ -94,6 +94,25 @@ public class CaseStatementTest extends BaseCoreFunctionalTestCase {
.list();
}
);
inTransaction(
s,
session -> {
try {
s.createQuery( "select case p.name when 'Steve' then :opt1 else :opt2 end from Person p" )
.setString( "opt1", "x" )
.setString( "opt2", "y" )
.list();
fail( "was expecting an exception" );
}
catch (IllegalArgumentException e) {
assertTyping( QueryException.class, e.getCause() );
}
catch (QueryException expected) {
// expected
}
}
);
}
}

View File

@ -79,8 +79,8 @@ public class InsertOrderingWithCascadeOnPersist extends BaseCoreFunctionalTestCa
@Access(AccessType.FIELD)
public static class MarketBid {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "MarketBid")
@TableGenerator(name = "MarketBid", pkColumnValue = "MarketBid", allocationSize = 10000)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "ID_TABLE")
@TableGenerator(name = "ID_TABLE", pkColumnValue = "MarketBid", allocationSize = 10000)
private Long id;
@ManyToOne(optional = false, cascade = CascadeType.PERSIST)
@ -99,8 +99,8 @@ public class InsertOrderingWithCascadeOnPersist extends BaseCoreFunctionalTestCa
@Access(AccessType.FIELD)
public static class MarketBidGroup {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "MarketBidGroup")
@TableGenerator(name = "MarketBidGroup", pkColumnValue = "MarketBidGroup", allocationSize = 10000)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "ID_TABLE")
@TableGenerator(name = "ID_TABLE", pkColumnValue = "MarketBidGroup", allocationSize = 10000)
private Long id;
@OneToMany(mappedBy = "group")
@ -115,8 +115,8 @@ public class InsertOrderingWithCascadeOnPersist extends BaseCoreFunctionalTestCa
@Access(AccessType.FIELD)
public static class MarketResult {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "MarketResult")
@TableGenerator(name = "MarketResult", pkColumnValue = "MarketResult", allocationSize = 10000)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "ID_TABLE")
@TableGenerator(name = "ID_TABLE", pkColumnValue = "MarketResult", allocationSize = 10000)
private Long id;
@ManyToOne(optional = false)

View File

@ -11,8 +11,6 @@ import javax.persistence.LockModeType;
import org.hibernate.test.jpa.AbstractJPATest;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;
/**
* @author Steve Ebersole
*/
@ -21,7 +19,6 @@ public class NonSelectQueryLockMode extends AbstractJPATest {
@Test( expected = IllegalStateException.class )
public void testNonSelectQueryGetLockMode() {
inTransaction(
sessionFactory(),
session -> session.createQuery( "delete Item" ).getLockMode()
);
}
@ -29,7 +26,6 @@ public class NonSelectQueryLockMode extends AbstractJPATest {
@Test( expected = IllegalStateException.class )
public void testNonSelectQuerySetLockMode() {
inTransaction(
sessionFactory(),
session -> session.createQuery( "delete Item" ).setLockMode( LockModeType.PESSIMISTIC_WRITE )
);
}

View File

@ -18,7 +18,6 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -41,7 +40,6 @@ public class ResultMappingTest extends BaseCoreFunctionalTestCase {
@Test
public void testResultClass() {
inTransaction(
sessionFactory(),
session -> {
final ProcedureCall call = session.createStoredProcedureCall(
"findOneUser",
@ -61,7 +59,6 @@ public class ResultMappingTest extends BaseCoreFunctionalTestCase {
@Test
public void testMappingAllFields() {
inTransaction(
sessionFactory(),
session -> {
final ProcedureCall call = session.createStoredProcedureCall( "findOneUser", "all-fields" );
final ProcedureOutputs procedureResult = call.getOutputs();
@ -78,7 +75,6 @@ public class ResultMappingTest extends BaseCoreFunctionalTestCase {
@Test
public void testMappingSomeFields() {
inTransaction(
sessionFactory(),
session -> {
final ProcedureCall call = session.createStoredProcedureCall( "findOneUser", "some-fields" );
final ProcedureOutputs procedureResult = call.getOutputs();
@ -95,7 +91,6 @@ public class ResultMappingTest extends BaseCoreFunctionalTestCase {
@Test
public void testMappingNoFields() {
inTransaction(
sessionFactory(),
session -> {
final ProcedureCall call = session.createStoredProcedureCall( "findOneUser", "no-fields" );
final ProcedureOutputs procedureResult = call.getOutputs();