[HHH-9994] Finish mariadb (mysql) database profile - added transaction to EnhancerTest and FlushAndTransactionTest
This commit is contained in:
parent
46232719d1
commit
37964f12e4
|
@ -20,9 +20,11 @@ public class HHH3949TestTask1 extends AbstractHHH3949TestTask {
|
|||
private void performQueryAndVerifyResults(String query) {
|
||||
// 1) open session
|
||||
Session session = getFactory().openSession();
|
||||
session.getTransaction().begin();
|
||||
// 2) perform the query
|
||||
List<Person> persons = (List<Person>) session.createQuery( query ).list();
|
||||
// 3) close the session : this ensures that no more queries and/or data loading happen
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
// 4) verify the results
|
||||
|
|
|
@ -17,9 +17,11 @@ public class HHH3949TestTask2 extends AbstractHHH3949TestTask {
|
|||
public void performQueryAndVerifyResults(String query) {
|
||||
// 1) open session
|
||||
Session session = getFactory().openSession();
|
||||
session.getTransaction().begin();
|
||||
// 2) perform the query
|
||||
List<Vehicle> vehicles = (List<Vehicle>) session.createQuery( query ).list();
|
||||
// 3) close the session : this ensures that no more queries and/or data loading happen
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
// 4) verify the results
|
||||
|
|
|
@ -12,6 +12,7 @@ public class HHH3949TestTask3 extends AbstractHHH3949TestTask {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void execute() {
|
||||
Session session = getFactory().openSession();
|
||||
session.getTransaction().begin();
|
||||
List<Person> persons = (List<Person>) session.createCriteria( Person.class )
|
||||
.setFetchMode( "vehicle", FetchMode.JOIN )
|
||||
.list();
|
||||
|
@ -21,6 +22,7 @@ public class HHH3949TestTask3 extends AbstractHHH3949TestTask {
|
|||
Assert.assertNotNull( person.getVehicle().getDriver() );
|
||||
}
|
||||
}
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,11 @@ public class HHH3949TestTask4 extends AbstractHHH3949TestTask {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void execute() {
|
||||
Session session = getFactory().openSession();
|
||||
session.getTransaction().begin();
|
||||
List<Vehicle> vehicles = (List<Vehicle>) session.createCriteria( Vehicle.class )
|
||||
.setFetchMode( "driver", FetchMode.JOIN )
|
||||
.list();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
for ( Vehicle vehicle : vehicles ) {
|
||||
|
|
|
@ -282,7 +282,9 @@ public class FlushAndTransactionTest extends BaseEntityManagerFunctionalTestCase
|
|||
book.name = "Recovered keys";
|
||||
em.merge( book );
|
||||
em.getTransaction().rollback();
|
||||
em.getTransaction().begin();
|
||||
assertEquals( "Stolen keys", em.find( Book.class, book.id ).name );
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue