当前位置: 首页>>代码示例>>Java>>正文


Java Transaction.commitRetaining方法代码示例

本文整理汇总了Java中com.haulmont.cuba.core.Transaction.commitRetaining方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.commitRetaining方法的具体用法?Java Transaction.commitRetaining怎么用?Java Transaction.commitRetaining使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.haulmont.cuba.core.Transaction的用法示例。


在下文中一共展示了Transaction.commitRetaining方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRemoveNotManaged

import com.haulmont.cuba.core.Transaction; //导入方法依赖的package包/类
@Test
public void testRemoveNotManaged() {
    System.out.println("===================== BEGIN testRemoveNotManaged =====================");

    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        UserRole userRole = em.find(UserRole.class, userRole1Id);

        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        em.remove(userRole);

        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        UserRole deletedUserRole = em.find(UserRole.class, userRole1Id);
        assertNull(deletedUserRole);

        tx.commit();
    } finally {
        tx.end();
    }
    System.out.println("===================== END testRemoveNotManaged =====================");
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:SoftDeleteTest.java

示例2: test

import com.haulmont.cuba.core.Transaction; //导入方法依赖的package包/类
@Test
public void test() {
    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();

        Role role = new Role();
        role.setName("testRole1");
        em.persist(role);

        Group group = new Group();
        group.setName("testGroup1");
        em.persist(group);

        User user = new User();
        UUID userId = user.getId();
        user.setLogin("testUser1");
        user.setName("Test User 1");
        user.setGroup(group);
        em.persist(user);

        UserRole userRole = new UserRole();
        userRole.setUser(user);
        userRole.setRole(role);
        em.persist(userRole);

        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        user = em.find(User.class, userId);
        List<UserRole> userRoles = user.getUserRoles();
        assertEquals(1, userRoles.size());
        for (UserRole ur : userRoles) {
            Role r = ur.getRole();
            assertEquals(role.getName(), r.getName());
        }
    } finally {
        tx.end();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:41,代码来源:UserRoleTest.java

示例3: createGroups

import com.haulmont.cuba.core.Transaction; //导入方法依赖的package包/类
private void createGroups() {
    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        Group root = new Group();
        rootId = root.getId();
        root.setName("root");
        em.persist(root);
        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        root = em.find(Group.class, rootId);
        Group group1 = new Group();
        group1Id = group1.getId();
        group1.setName("group1");
        group1.setParent(root);
        em.persist(group1);
        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        group1 = em.find(Group.class, group1Id);
        Group group2 = new Group();
        group2Id = group2.getId();
        group2.setName("group2");
        group2.setParent(group1);
        em.persist(group2);
        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        root = em.find(Group.class, rootId);
        Group group3 = new Group();
        group3Id = group3.getId();
        group3.setName("group3");
        group3.setParent(root);
        em.persist(group3);
        tx.commit();
    } finally {
        tx.end();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:41,代码来源:GroupTest.java

示例4: setUp

import com.haulmont.cuba.core.Transaction; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    passwordEncryption = AppBeans.get(PasswordEncryption.class);

    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();

        Group parentGroup = new Group();
        parentGroupId = parentGroup.getId();
        parentGroup.setName("testParentGroup");
        em.persist(parentGroup);

        tx.commitRetaining();
        em = cont.persistence().getEntityManager();

        Group group = new Group();
        groupId = group.getId();
        group.setName("testGroup");
        group.setParent(parentGroup);
        em.persist(group);

        Constraint userConstraint = new Constraint();
        userConstraintId = userConstraint.getId();
        userConstraint.setEntityName("sec$User");
        userConstraint.setJoinClause("join {E}.userRoles ur");
        userConstraint.setWhereClause("{E}.id is not null");
        userConstraint.setGroup(group);
        em.persist(userConstraint);

        User user = new User();
        user1Id = user.getId();
        user.setLogin(USER_LOGIN);

        String pwd = passwordEncryption.getPasswordHash(user1Id, USER_PASSW);
        user.setPassword(pwd);

        user.setGroup(group);
        em.persist(user);

        User user2 = new User();
        user2.setGroup(parentGroup);
        user2Id = user2.getId();
        user2.setLogin("someOtherUser");
        em.persist(user2);

        Role role1 = new Role();
        role1.setName("TestRole1");
        role1Id = role1.getId();
        em.persist(role1);

        Role role2 = new Role();
        role2.setName("TestRole2");
        role2Id = role2.getId();
        em.persist(role2);

        UserRole userRole1 = new UserRole();
        userRole1Id = userRole1.getId();
        userRole1.setUser(user2);
        userRole1.setRole(role1);
        em.persist(userRole1);

        UserRole userRole2 = new UserRole();
        userRole2Id = userRole2.getId();
        userRole2.setUser(user2);
        userRole2.setRole(role2);
        em.persist(userRole2);

        tx.commit();
    } finally {
        tx.end();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:74,代码来源:DistinctConstraintTest.java

示例5: setUp

import com.haulmont.cuba.core.Transaction; //导入方法依赖的package包/类
@Before
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();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:45,代码来源:SoftDeleteNotFoundDeletedTest.java


注:本文中的com.haulmont.cuba.core.Transaction.commitRetaining方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。