use of org.hibernate.test.cache.infinispan.stress.entities.Family in project hibernate-orm by hibernate.
the class CorrectnessTestCase method createFamily.
private static Family createFamily() {
ThreadLocalRandom random = ThreadLocalRandom.current();
String familyName = randomString(random);
Family f = new Family(familyName);
HashSet<Person> members = new HashSet<>();
members.add(createPerson(random, f));
f.setMembers(members);
return f;
}
use of org.hibernate.test.cache.infinispan.stress.entities.Family in project hibernate-orm by hibernate.
the class SecondLevelCacheStressTestCase method insertOperation.
Operation insertOperation() {
return new Operation("INSERT") {
@Override
boolean call(final int run) throws Exception {
return captureThrowables(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return withTx(tm, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
Session s = sessionFactory.openSession();
s.getTransaction().begin();
String name = "Zamarreño-" + run;
Family family = new Family(name);
s.persist(family);
s.getTransaction().commit();
s.close();
return true;
}
});
}
});
}
};
}
use of org.hibernate.test.cache.infinispan.stress.entities.Family in project hibernate-orm by hibernate.
the class SecondLevelCacheStressTestCase method deleteOperation.
private Operation deleteOperation() {
return new Operation("DELETE") {
@Override
boolean call(final int run) throws Exception {
return captureThrowables(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return withTx(tm, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
Session s = sessionFactory.openSession();
s.getTransaction().begin();
// Get each id and remove it
int id = removeIds.poll();
Family family = (Family) s.load(Family.class, id);
String familyName = family.getName();
// Skip ñ check in order to avoid issues...
assertTrue("Unexpected family: " + familyName, familyName.startsWith("Zamarre"));
s.delete(family);
s.getTransaction().commit();
s.close();
return true;
}
});
}
});
}
};
}
use of org.hibernate.test.cache.infinispan.stress.entities.Family in project hibernate-orm by hibernate.
the class SecondLevelCacheStressTestCase method updateOperation.
Operation updateOperation() {
return new Operation("UPDATE") {
@Override
boolean call(final int run) throws Exception {
return captureThrowables(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return withTx(tm, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
Session s = sessionFactory.openSession();
s.getTransaction().begin();
// Update random entity that has been inserted
int id = RANDOM.nextInt(numEntities) + 1;
Family family = (Family) s.load(Family.class, id);
String newSecondName = "Arrizabalaga-" + run;
family.setSecondName(newSecondName);
s.getTransaction().commit();
s.close();
// Cache updated entities for later read
updatedIds.add(id);
return true;
}
});
}
});
}
};
}
Aggregations