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


Java Transaction.failure方法代码示例

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


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

示例1: close

import org.neo4j.graphdb.Transaction; //导入方法依赖的package包/类
/**
 * Ends and closes a transaction.
 */
public void close() {
    CurrentTransaction currentTransaction = transactions.removeLast();
    Transaction transaction = currentTransaction.transaction;

    if (currentTransaction.success) {
        logger.debug("[close] Transaction success");
        transaction.success();
    }
    else {
        logger.debug("[close] Transaction failure");
        transaction.failure();
    }

    transaction.close();

    logger.debug("[close] Transaction closed");
}
 
开发者ID:owetterau,项目名称:neo4j-websockets,代码行数:21,代码来源:DatabaseCallAspect.java

示例2: storeShortUrl

import org.neo4j.graphdb.Transaction; //导入方法依赖的package包/类
@Override
public void storeShortUrl(ShortUrl shortUrl) {
    Transaction tx = db.beginTx();
    try {
        Node node = template.createNode(new Property(KEY, shortUrl.getKey()));
        node.setProperty(LONG_URL, shortUrl.getLongUrl());
        node.setProperty(USER_ID, shortUrl.getUser().getId());
        index.index(node, KEY, shortUrl.getKey());
        tx.success();
    } catch (Exception ex) {
        logger.error("Problem shortening url in the graph", ex);
        tx.failure();
    } finally {
        tx.finish();
    }

}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:18,代码来源:ViralLinkDaoNeo4j.java

示例3: followingTest

import org.neo4j.graphdb.Transaction; //导入方法依赖的package包/类
@Test
public void followingTest() throws Exception {
    Transaction tx = db.beginTx();
    User user = new User();
    user.setId("foo");
    user.setUsername("ufoo");
    User followed = new User();
    followed.setId("bar");
    followed.setUsername("ubar");
    Following f = new Following();
    f.setFollower(user);
    f.setFollowed(followed);
    try {
        dao.saveFollowing(f);
        tx.success();
    } catch (Exception ex) {
        tx.failure();
        throw ex;
    } finally {
        tx.finish();
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:23,代码来源:FollowingTest.java

示例4: migrateFollowingGraph

import org.neo4j.graphdb.Transaction; //导入方法依赖的package包/类
@Async
public void migrateFollowingGraph() {
    // the jpa dao only needed here, no need to live in the context
    FollowingDaoJpa dao = new FollowingDaoJpa();
    ctx.getAutowireCapableBeanFactory().autowireBean(dao);

    List<User> users = userDao.list(User.class);

    Transaction tx = graphDb.beginTx();
    try {
        for (User user : users) {
            List<User> followers = dao.getFollowers(user);
            for (User follower : followers) {
                if (follower.equals(user)) {
                    continue;
                }
                Following following = dao.findFollowing(follower, user, false);
                if (following.getDateTime() == null) {
                    following.setDateTime(new DateTime().minusMonths(2));
                }
                if (following != null && followingDao.findFollowing(follower, user, false) == null) {
                    followingDao.saveFollowing(following);
                }
            }
        }
        tx.success();
    } catch (RuntimeException ex) {
        tx.failure();
        logger.error("GraphDB transaction problem", ex);
        throw ex;
    } finally {
        tx.finish();
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:35,代码来源:InternalService.java


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