use of org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate in project cuba by cuba-platform.
the class EntityCacheTestClass method setUp.
@Before
public void setUp() throws Exception {
assertTrue(cont.getSpringAppContext() == AppContext.getApplicationContext());
try (Transaction tx = cont.persistence().createTransaction()) {
EntityManagerFactory emf = cont.entityManager().getDelegate().getEntityManagerFactory();
assertTrue(cont.metadata().getTools().isCacheable(cont.metadata().getClassNN(User.class)));
assertFalse(cont.metadata().getTools().isCacheable(cont.metadata().getClassNN(UserSubstitution.class)));
ServerSession serverSession = ((EntityManagerFactoryDelegate) emf).getServerSession();
ClassDescriptor descriptor = serverSession.getDescriptor(User.class);
assertEquals(500, descriptor.getCachePolicy().getIdentityMapSize());
// assertTrue(Boolean.valueOf((String) emf.getProperties().get("eclipselink.cache.shared.default")));
// assertTrue(Boolean.valueOf((String) emf.getProperties().get("eclipselink.cache.shared.sec$User")));
this.cache = (JpaCache) emf.getCache();
group = cont.metadata().create(Group.class);
group.setName("group-" + group.getId());
cont.entityManager().persist(group);
user = cont.metadata().create(User.class);
user.setLogin("ECTest-" + user.getId());
user.setPassword("111");
user.setGroup(group);
cont.entityManager().persist(user);
user2 = cont.metadata().create(User.class);
user2.setLogin("ECTest-" + user2.getId());
user2.setPassword("111");
user2.setGroup(group);
cont.entityManager().persist(user2);
role = cont.metadata().create(Role.class);
role.setName("Test role");
role.setDescription("Test role descr");
cont.entityManager().persist(role);
userRole = cont.metadata().create(UserRole.class);
userRole.setRole(role);
userRole.setUser(user);
cont.entityManager().persist(userRole);
userSetting = cont.metadata().create(UserSetting.class);
userSetting.setUser(user);
cont.entityManager().persist(userSetting);
tx.commit();
}
cache.clear();
}
use of org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate in project cuba by cuba-platform.
the class QueryCacheTestClass method setUp.
@Before
public void setUp() throws Exception {
assertTrue(cont.getSpringAppContext() == AppContext.getApplicationContext());
queryCache = AppBeans.get(QueryCache.NAME);
try (Transaction tx = cont.persistence().createTransaction()) {
EntityManagerFactory emf = cont.entityManager().getDelegate().getEntityManagerFactory();
assertTrue(cont.metadata().getTools().isCacheable(cont.metadata().getClassNN(User.class)));
assertFalse(cont.metadata().getTools().isCacheable(cont.metadata().getClassNN(UserSubstitution.class)));
ServerSession serverSession = ((EntityManagerFactoryDelegate) emf).getServerSession();
ClassDescriptor descriptor = serverSession.getDescriptor(User.class);
assertEquals(500, descriptor.getCachePolicy().getIdentityMapSize());
this.cache = (JpaCache) emf.getCache();
group = cont.metadata().create(Group.class);
group.setName("group-" + group.getId());
cont.entityManager().persist(group);
user = cont.metadata().create(User.class);
user.setLogin("ECTest-" + user.getId());
user.setPassword("111");
user.setName("1");
user.setGroup(group);
cont.entityManager().persist(user);
user2 = cont.metadata().create(User.class);
user2.setLogin("ECTest-" + user2.getId());
user2.setPassword("111");
user2.setName("2");
user2.setGroup(group);
cont.entityManager().persist(user2);
user3 = cont.metadata().create(User.class);
user3.setLogin("ECTest-" + user3.getId());
user3.setPassword("111");
user3.setGroup(group);
cont.entityManager().persist(user3);
role = cont.metadata().create(Role.class);
role.setName("TestRole");
role.setDescription("Test role descr");
cont.entityManager().persist(role);
userRole = cont.metadata().create(UserRole.class);
userRole.setRole(role);
userRole.setUser(user);
cont.entityManager().persist(userRole);
userSetting = cont.metadata().create(UserSetting.class);
userSetting.setUser(user);
cont.entityManager().persist(userSetting);
tx.commit();
}
try (Transaction tx = cont.persistence().createTransaction()) {
cont.entityManager().remove(user3);
tx.commit();
}
cache.clear();
queryCache.invalidateAll();
}
Aggregations