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


Java SQLUpdateClause类代码示例

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


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


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