Search in sources :

Example 1 with Person

use of cn.taketoday.test.context.junit4.orm.domain.Person in project spring-framework-debug by Joker-5.

the class HibernateSessionFlushingTests method findSam.

@Test
public void findSam() {
    Person sam = personService.findByName(SAM);
    assertThat(sam).as("Should be able to find Sam").isNotNull();
    DriversLicense driversLicense = sam.getDriversLicense();
    assertThat(driversLicense).as("Sam's driver's license should not be null").isNotNull();
    assertThat(driversLicense.getNumber()).as("Verifying Sam's driver's license number").isEqualTo(Long.valueOf(1234));
}
Also used : DriversLicense(org.springframework.test.context.junit4.orm.domain.DriversLicense) Person(org.springframework.test.context.junit4.orm.domain.Person) Test(org.junit.Test)

Example 2 with Person

use of cn.taketoday.test.context.junit4.orm.domain.Person in project spring-framework-debug by Joker-5.

the class HibernateSessionFlushingTests method updateSamWithNullDriversLicense.

private void updateSamWithNullDriversLicense() {
    Person sam = personService.findByName(SAM);
    assertThat(sam).as("Should be able to find Sam").isNotNull();
    sam.setDriversLicense(null);
    personService.save(sam);
}
Also used : Person(org.springframework.test.context.junit4.orm.domain.Person)

Example 3 with Person

use of cn.taketoday.test.context.junit4.orm.domain.Person in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.

the class HibernateSessionFlushingTests method findSamWithReadOnlySession.

// SPR-16956
@Test
@Transactional(readOnly = true)
public void findSamWithReadOnlySession() {
    Person sam = personService.findByName(SAM);
    sam.setName("Vlad");
    // By setting setDefaultReadOnly(true), the user can no longer modify any entity...
    Session session = sessionFactory.getCurrentSession();
    session.flush();
    session.refresh(sam);
    assertThat(sam.getName()).isEqualTo("Sam");
}
Also used : Person(org.springframework.test.context.junit4.orm.domain.Person) Session(org.hibernate.Session) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Person

use of cn.taketoday.test.context.junit4.orm.domain.Person in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.

the class HibernateSessionFlushingTests method findSam.

@Test
public void findSam() {
    Person sam = personService.findByName(SAM);
    assertThat(sam).as("Should be able to find Sam").isNotNull();
    DriversLicense driversLicense = sam.getDriversLicense();
    assertThat(driversLicense).as("Sam's driver's license should not be null").isNotNull();
    assertThat(driversLicense.getNumber()).as("Verifying Sam's driver's license number").isEqualTo(Long.valueOf(1234));
}
Also used : DriversLicense(org.springframework.test.context.junit4.orm.domain.DriversLicense) Person(org.springframework.test.context.junit4.orm.domain.Person) Test(org.junit.Test)

Example 5 with Person

use of cn.taketoday.test.context.junit4.orm.domain.Person in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.

the class HibernateSessionFlushingTests method updateSamWithNullDriversLicense.

private void updateSamWithNullDriversLicense() {
    Person sam = personService.findByName(SAM);
    assertThat(sam).as("Should be able to find Sam").isNotNull();
    sam.setDriversLicense(null);
    personService.save(sam);
}
Also used : Person(org.springframework.test.context.junit4.orm.domain.Person)

Aggregations

Test (org.junit.Test)18 Person (org.springframework.test.context.junit4.orm.domain.Person)16 Person (cn.taketoday.test.context.junit4.orm.domain.Person)8 DriversLicense (org.springframework.test.context.junit4.orm.domain.DriversLicense)8 Session (org.hibernate.Session)6 DriversLicense (cn.taketoday.test.context.junit4.orm.domain.DriversLicense)4 Transactional (org.springframework.transaction.annotation.Transactional)4 Transactional (cn.taketoday.transaction.annotation.Transactional)2