HHH-17284 Fix indentation in caching tests/documentation

This commit is contained in:
Daniel Kraus 2023-10-03 14:38:33 +02:00 committed by Christian Beikov
parent 9bbac65523
commit b19ca2dadc
3 changed files with 56 additions and 56 deletions

View File

@ -44,8 +44,8 @@ public class FirstLevelCacheTest {
entityManager.persist(new Person());
entityManager.persist(new Person());
Person person = new Person();
entityManager.persist(person);
});
entityManager.persist(person);
});
scope.inTransaction( entityManager -> {
List<Object> dtos = new ArrayList<>();
//tag::caching-management-jpa-detach-example[]
@ -86,7 +86,7 @@ public class FirstLevelCacheTest {
session.contains(person);
//end::caching-management-contains-example[]
});
}
}
private Object toDTO(Person person) {
return person;

View File

@ -65,16 +65,16 @@ public class NonStrictReadWriteCacheTest {
);
}
@Test
public void testCache(EntityManagerFactoryScope scope) {
scope.inTransaction( entityManager -> {
@Test
public void testCache(EntityManagerFactoryScope scope) {
scope.inTransaction( entityManager -> {
Person person = new Person();
entityManager.persist(person);
entityManager.persist(person);
Phone home = new Phone("123-456-7890");
Phone office = new Phone("098-765-4321");
person.addPhone(home);
person.addPhone(office);
});
});
scope.inTransaction( entityManager -> {
Person person = entityManager.find(Person.class, 1L);
person.getPhones().size();
@ -88,21 +88,21 @@ public class NonStrictReadWriteCacheTest {
});
scope.inTransaction( entityManager -> {
log.info("Load from cache");
entityManager.find(Person.class, 1L).getPhones().size();
});
}
entityManager.find(Person.class, 1L).getPhones().size();
});
}
@Entity(name = "Person")
@Entity(name = "Person")
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public static class Person {
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public static class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String name;
//tag::caching-collection-mapping-example[]
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL)
@ -110,26 +110,26 @@ public class NonStrictReadWriteCacheTest {
private List<Phone> phones = new ArrayList<>();
//end::caching-collection-mapping-example[]
@Version
private int version;
@Version
private int version;
public Person() {}
public Person() {}
public Person(String name) {
this.name = name;
}
public Person(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public List<Phone> getPhones() {
return phones;

View File

@ -55,15 +55,15 @@ import static org.junit.Assert.assertNotNull;
public class SecondLevelCacheTest {
private final Logger log = Logger.getLogger( SecondLevelCacheTest.class );
@Test
public void testCache(EntityManagerFactoryScope scope) {
scope.inTransaction( entityManager -> {
entityManager.persist(new Person());
@Test
public void testCache(EntityManagerFactoryScope scope) {
scope.inTransaction( entityManager -> {
entityManager.persist(new Person());
Person aPerson= new Person();
aPerson.setName("John Doe");
aPerson.setCode("unique-code");
entityManager.persist(aPerson);
});
entityManager.persist(aPerson);
});
scope.inTransaction( entityManager -> {
log.info("Jpa load by id");
@ -249,13 +249,13 @@ public class SecondLevelCacheTest {
@Entity(name = "Person")
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public static class Person {
public static class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String name;
@NaturalId
@Column(name = "code", unique = true)
@ -267,21 +267,21 @@ public class SecondLevelCacheTest {
public Person() {}
public Person(String name) {
this.name = name;
}
public Person(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;