當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。