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