use of com.haulmont.cuba.core.Transaction in project cuba by cuba-platform.
the class RelationsTest method createRole.
public UUID createRole() {
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
User user = em.find(User.class, UUID.fromString("60885987-1b61-4247-94c7-dff348347f93"));
Role role = new Role();
role.setName("RelationTest");
em.persist(role);
UserRole userRole = new UserRole();
userRole.setUser(user);
userRole.setRole(role);
em.persist(userRole);
tx.commit();
return role.getId();
} finally {
tx.end();
}
}
use of com.haulmont.cuba.core.Transaction in project cuba by cuba-platform.
the class UserSettingServiceTest method tearDown.
@AfterEach
public void tearDown() throws Exception {
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
Query q = em.createNativeQuery("delete from SEC_USER_SETTING where USER_ID = ?");
q.setParameter(1, TestUserSessionSource.USER_ID);
q.executeUpdate();
tx.commit();
} finally {
tx.end();
}
}
use of com.haulmont.cuba.core.Transaction in project cuba by cuba-platform.
the class SoftDeleteDataManagerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
persistence = cont.persistence();
metadata = cont.metadata();
try (Transaction tx = persistence.createTransaction()) {
user = metadata.create(User.class);
user.setGroup(persistence.getEntityManager().find(Group.class, TestSupport.COMPANY_GROUP_ID));
user.setLogin("user-" + user.getId());
persistence.getEntityManager().persist(user);
tx.commit();
}
}
use of com.haulmont.cuba.core.Transaction in project cuba by cuba-platform.
the class SoftDeleteNotFoundDeletedTest method setUp.
@BeforeEach
public void setUp() throws Exception {
dataManager = AppBeans.get(DataManager.class);
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
SoftDelete_Service service = new SoftDelete_Service();
serviceId = service.getId();
service.setName("service");
service.setCode("serviceCode");
em.persist(service);
SoftDelete_Task task = new SoftDelete_Task();
taskId = task.getId();
task.setMessage("message");
task.setService(service);
em.persist(task);
SoftDelete_TaskValue taskValue = new SoftDelete_TaskValue();
taskValueId = taskValue.getId();
taskValue.setTask(task);
em.persist(taskValue);
SoftDelete_Project project = new SoftDelete_Project();
projectId = project.getId();
project.setName("project");
project.setAValue(taskValue);
project.setTask(task);
em.persist(project);
tx.commitRetaining();
em = cont.persistence().getEntityManager();
task = em.find(SoftDelete_Task.class, taskId);
em.remove(task);
tx.commit();
} finally {
tx.end();
}
}
use of com.haulmont.cuba.core.Transaction in project cuba by cuba-platform.
the class EntityLogTest method setUp.
@BeforeEach
public void setUp() throws Exception {
cleanup();
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
Query q;
q = em.createNativeQuery("delete from SEC_ENTITY_LOG");
q.executeUpdate();
LoggedEntity le = new LoggedEntity();
le.setName("sec$User");
le.setAuto(true);
em.persist(le);
LoggedAttribute la = new LoggedAttribute();
la.setEntity(le);
la.setName("email");
em.persist(la);
le = new LoggedEntity();
le.setName("sec$Role");
le.setAuto(true);
em.persist(le);
la = new LoggedAttribute();
la.setEntity(le);
la.setName("type");
em.persist(la);
tx.commit();
} finally {
tx.end();
}
entityLog = AppBeans.get(EntityLogAPI.NAME);
entityLog.invalidateCache();
}
Aggregations