• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SQLUpdateClause类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mysema.query.sql.dml.SQLUpdateClause的典型用法代码示例。如果您正苦于以下问题:Java SQLUpdateClause类的具体用法?Java SQLUpdateClause怎么用?Java SQLUpdateClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SQLUpdateClause类属于com.mysema.query.sql.dml包,在下文中一共展示了SQLUpdateClause类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: modifyBalance

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public void modifyBalance(int i, long amount, String description) {
    if (i < 0)
        return;

    QBalance b = QBalance.balance;
    QTransactions t = QTransactions.transactions;

    try {
        SQLInsertClause balanceClause = DatabaseManager.getInstance().getInsertClause(b);
        SQLInsertClause transactionClause = DatabaseManager.getInstance().getInsertClause(t);

        transactionClause.columns(t.id, t.description, t.amount).values(i, description, amount).execute();
        balanceClause.columns(b.id, b.amount).values(i, amount).execute();
    } catch (QueryException e) {
        // Transaction insert won't fail, only balance will. when it does, update instead
        SQLUpdateClause clause = DatabaseManager.getInstance().getUpdateClause(b);

        clause.where(b.id.eq(i)).set(b.amount, b.amount.add(amount)).execute();
    }
}
 
开发者ID:DemonWav,项目名称:EctoTokens,代码行数:21,代码来源:TokensManager.java


示例2: setBalance

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public void setBalance(int i, long amount, String description) {
    if (i < 0)
        return;

    QBalance b = QBalance.balance;
    QTransactions t = QTransactions.transactions;

    // We need to know the current amount to get the amount changed for the transaction log
    SQLQuery query = DatabaseManager.getInstance().getNewQuery();
    Long current = query.from(b).where(b.id.eq(i)).uniqueResult(b.amount);
    current = current == null ? 0 : current;

    try {
        SQLInsertClause balanceClause = DatabaseManager.getInstance().getInsertClause(b);
        SQLInsertClause transactionClause = DatabaseManager.getInstance().getInsertClause(t);

        transactionClause.columns(t.id, t.description, t.amount).values(i, description, amount - current).execute();
        balanceClause.columns(b.id, b.amount).values(i, amount).execute();
    } catch (QueryException e) {
        // Transaction insert won't fail, only balance will. when it does, update instead
        SQLUpdateClause clause = DatabaseManager.getInstance().getUpdateClause(b);

        clause.where(b.id.eq(i)).set(b.amount, amount).execute();
    }
}
 
开发者ID:DemonWav,项目名称:EctoTokens,代码行数:26,代码来源:TokensManager.java


示例3: updateInitiative

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void updateInitiative(InitiativeManagement initiative, Long userId, boolean basic, boolean extra) {
    Assert.notNull(initiative, "initiative");
    Assert.notNull(userId, "userId");

    Long initiativeId = initiative.getId();
    Assert.notNull(initiativeId, "initiative.id");

    SQLUpdateClause update = queryFactory.update(qInitiative);
    populateInitiative(update, initiative, userId, basic, extra);
    update.where(qInitiative.id.eq(initiative.getId()));
    
    if (update.execute() != 1) {
        throw new NotFoundException(qInitiative.getTableName(), initiative.getId());
    } 
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:18,代码来源:InitiativeDaoImpl.java


示例4: updateLink

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void updateLink(Link link, Long initiativeId) {
    Long linkId = link.getId();
    Assert.notNull(linkId, "link.id");

    SQLUpdateClause update = queryFactory
            .update(qInitiativeLink)
            .where(
                    qInitiativeLink.id.eq(linkId),
                    qInitiativeLink.initiativeId.eq(initiativeId) // Defensive... 
                );
    populateLink(update, link);
    
    if (update.execute() != 1) {
        throw new NotFoundException(qInitiativeLink.getTableName(), linkId);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:17,代码来源:InitiativeDaoImpl.java


示例5: updateUnsentInvitation

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private void updateUnsentInvitation(Long initiativeId, Invitation invitation) {
    if (invitation.getSent() == null) {
        Long invitationId = invitation.getId();
        Assert.notNull(invitationId, "invitation.id");

        SQLUpdateClause update = queryFactory
                .update(qInvitation)
                .where(
                        qInvitation.id.eq(invitationId),
                        qInvitation.initiativeId.eq(initiativeId) // Defensive... 
                    );
        update.set(qInvitation.email, invitation.getEmail());
        
        if (update.execute() != 1) {
            throw new NotFoundException(qInitiativeLink.getTableName(), invitationId);
        }
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:19,代码来源:InitiativeDaoImpl.java


示例6: updateInvitationSent

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void updateInvitationSent(Long initiativeId, Long invitationId, String invitationCode) {
    Assert.notNull(initiativeId, "initiativeId");
    Assert.notNull(invitationId, "invitationId");
    Assert.notNull(invitationCode, "invitationCode");

    SQLUpdateClause update = queryFactory
            .update(qInvitation)
            .where(
                    qInvitation.id.eq(invitationId),
                    qInvitation.initiativeId.eq(initiativeId),  // Defensive... 
                    qInvitation.sent.isNull()
                );
    update.set(qInvitation.sent, CURRENT_TIME);
    update.set(qInvitation.invitationcode, invitationCode);
    
    if (update.execute() != 1) {
        throw new NotFoundException(qInvitation.getTableName(), invitationId);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:22,代码来源:InitiativeDaoImpl.java


示例7: execute

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
public Long execute() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    return jdbcTemplate.execute(new ConnectionCallback<Long>() {
        @Override
        public Long doInConnection(Connection connection) throws SQLException, DataAccessException {
            final SQLUpdateClause updateClause = new SQLUpdateClause(connection, configuration, pathBase);
            addSpec(updateClause);
            populate(updateClause);
            log(updateClause);
            return updateClause.execute();
        }
    });
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:14,代码来源:UpdateTransaction.java


示例8: populate

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
/**
 * 因为需要忽略createdTime、updatedTime,所以并没有直接使用 updateClause.populate(domain)或updateClause.populate(domain, DefaultMapper.WITH_NULL_BINDINGS)来实现set
 *
 * @param updateClause
 * @param obj
 * @param mapper
 */
public void populate(SQLUpdateClause updateClause, T obj, DefaultMapper mapper) {
    Collection<? extends Path<?>> primaryKeyColumns = pathBase.getPrimaryKey() != null
            ? pathBase.getPrimaryKey().getLocalColumns()
            : Collections.<Path<?>>emptyList();
    Map<Path<?>, Object> values = mapper.createMap(pathBase, obj);
    for (Map.Entry<Path<?>, Object> entry : values.entrySet()) {
        if (!primaryKeyColumns.contains(entry.getKey()) && !ignoreColumns.contains(entry.getKey().getMetadata().getName())) {
            updateClause.set((Path) entry.getKey(), entry.getValue());
        }
    }
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:19,代码来源:UpdateTransaction.java


示例9: updateInitiativeState

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void updateInitiativeState(Long initiativeId, Long userId, InitiativeState state, String comment) {
    SQLUpdateClause update = getUpdateClauseForInitiativeState(initiativeId, userId, state, comment);

    if (update.execute() != 1) {
        throw new NotFoundException(qInitiative.getTableName(), initiativeId);
    } 
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:10,代码来源:InitiativeDaoImpl.java


示例10: updateInitiativeStateAndAcceptanceIdentifier

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void updateInitiativeStateAndAcceptanceIdentifier(Long initiativeId, Long userId, InitiativeState state, String comment, String acceptanceIdentifier) {
    SQLUpdateClause update = getUpdateClauseForInitiativeState(initiativeId, userId, state, comment)
            .set(qInitiative.acceptanceidentifier, acceptanceIdentifier);

    if (update.execute() != 1) {
        throw new NotFoundException(qInitiative.getTableName(), initiativeId);
    } 
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:11,代码来源:InitiativeDaoImpl.java


示例11: getUpdateClauseForInitiativeState

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
private SQLUpdateClause getUpdateClauseForInitiativeState(Long initiativeId, Long userId, InitiativeState state, String comment) {
    Assert.notNull(initiativeId, "initiative.id");
    return queryFactory.update(qInitiative)
            .set(qInitiative.modifierId, userId)
            .set(qInitiative.modified, CURRENT_TIME)
            .set(qInitiative.state, state)
            .set(qInitiative.statecomment, comment)
            .set(qInitiative.statedate, CURRENT_TIME) 
            .where(qInitiative.id.eq(initiativeId));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:11,代码来源:InitiativeDaoImpl.java


示例12: updateSendToParliament

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly = false)
public void updateSendToParliament(Long initiativeId, SendToParliamentData data) {
    SQLUpdateClause update = queryFactory.update(qInitiative)
            .set(qInitiative.parliamentidentifier, data.getParliamentIdentifier())
            .set(qInitiative.parliamentsenttime, data.getParliamentSentTime())
            .set(qInitiative.parliamenturl, data.getParliamentURL())
            .set(qInitiative.state, InitiativeState.DONE)
            .set(qInitiative.statedate, CURRENT_TIME)
            .where(qInitiative.id.eq(initiativeId));

    if (update.execute() != 1) {
        throw new NotFoundException(qInitiative.getTableName(), initiativeId);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:16,代码来源:InitiativeDaoImpl.java


示例13: endInitiative

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
public void endInitiative(Long initiativeId, LocalDate lastRunningDate) {
    SQLUpdateClause update = queryFactory.update(qInitiative)
            .set(qInitiative.enddate, lastRunningDate)
            .where(qInitiative.id.eq(initiativeId));

    if (update.execute() != 1) {
        throw new NotFoundException(qInitiative.getTableName(), initiativeId);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:11,代码来源:InitiativeDaoImpl.java


示例14: clearConfirmations

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void clearConfirmations(Long initiativeId, Long userId) {
    Expression<DateTime> confirmed = new CaseBuilder()
        .when(qAuthor.userId.eq(userId))
        .then(CURRENT_TIME)
        .otherwise(NULL_TIME);

    SQLUpdateClause update = queryFactory.update(qAuthor)
        .set(qAuthor.confirmed, confirmed)
        .set(qAuthor.confirmationrequestsent, NULL_TIME)
        .where(qAuthor.initiativeId.eq(initiativeId));

    update.execute();
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:16,代码来源:InitiativeDaoImpl.java


示例15: updateConfirmationRequestSent

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void updateConfirmationRequestSent(Long initiativeId, Long userId) {
    SQLUpdateClause update = queryFactory.update(qAuthor)
            .set(qAuthor.confirmationrequestsent, CURRENT_TIME)
            .where(qAuthor.initiativeId.eq(initiativeId), qAuthor.userId.eq(userId));

    update.execute();
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:10,代码来源:InitiativeDaoImpl.java


示例16: confirmAuthor

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void confirmAuthor(Long initiativeId, Long userId) {
    SQLUpdateClause update = queryFactory.update(qAuthor)
            .set(qAuthor.confirmed, CURRENT_TIME)
            .where(qAuthor.initiativeId.eq(initiativeId), qAuthor.userId.eq(userId));

    if (update.execute() != 1) {
        throw new NotFoundException("author", initiativeId + ":" + userId);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:12,代码来源:InitiativeDaoImpl.java


示例17: updateAuthor

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void updateAuthor(Long initiativeId, Long userId, Author author) {
    SQLUpdateClause update = queryFactory
            .update(qAuthor)
            .where(qAuthor.initiativeId.eq(initiativeId), qAuthor.userId.eq(userId));
    
    populateAuthor(update, author);
    
    if (update.execute() != 1) {
        throw new NotFoundException("author", initiativeId + ":" + userId);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:14,代码来源:InitiativeDaoImpl.java


示例18: incrementSupportCount

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public void incrementSupportCount(Long initiativeId) {
    // Increment Initiative.supportCount
    SQLUpdateClause update = queryFactory.update(qInitiative)
            .set(qInitiative.supportcount, qInitiative.supportcount.add(1))
            .where(qInitiative.id.eq(initiativeId));
    update.execute();
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:10,代码来源:SupportVoteDaoImpl.java


示例19: loginRegisteredUser

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
@Transactional(readOnly=false)
public User loginRegisteredUser(String ssnHash) {
    User user = getRegisteredUser(ssnHash);
    if (user != null) {
        SQLUpdateClause update = queryFactory.update(qUser);
        update.set(qUser.lastlogin, new DateTime());
        update.where(qUser.id.eq(user.getId()));
        update.execute();
    }
    return user;
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:13,代码来源:UserDaoImpl.java


示例20: setUserRoles

import com.mysema.query.sql.dml.SQLUpdateClause; //导入依赖的package包/类
@Override
public void setUserRoles(Long userId, boolean vrk, boolean om) {
    Assert.notNull(userId, "userId");
    SQLUpdateClause update = queryFactory.update(qUser);
    update.set(qUser.vrk, vrk);
    update.set(qUser.om, om);
    update.where(qUser.id.eq(userId));
    update.execute();
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:10,代码来源:UserDaoImpl.java



注:本文中的com.mysema.query.sql.dml.SQLUpdateClause类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockTargetPair类代码示例发布时间:2022-05-22
下一篇:
Java RexUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap