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


Java SQLInsertClause类代码示例

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


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

示例1: modifyBalance

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的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.SQLInsertClause; //导入依赖的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: saveDenormalizedSupportCountData

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Override
@Transactional(readOnly = false)
public void saveDenormalizedSupportCountData(Long initiativeId, Map<LocalDate, Long> denormalizedData) {

    if (!denormalizedData.isEmpty()) {

        queryFactory.delete(initiativeSupportVoteDay).where(initiativeSupportVoteDay.initiativeId.eq(initiativeId)).execute();

        SQLInsertClause insert = queryFactory.insert(initiativeSupportVoteDay);
        for (Map.Entry<LocalDate, Long> localDateLongEntry : denormalizedData.entrySet()) {
            insert.set(initiativeSupportVoteDay.initiativeId, initiativeId)
                    .set(initiativeSupportVoteDay.supportCount, localDateLongEntry.getValue().intValue())
                    .set(initiativeSupportVoteDay.supportDate, localDateLongEntry.getKey())
                    .addBatch();
        }

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

示例4: createMailLog

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
private long createMailLog(final String launcherId, final LocalDateTime launchedAt, final String messageName,
		final LocalDateTime scheduledAt, final String from, final String subject, final String body) {
	final QMailLog a = new QMailLog("a");
	SqlInsertWithKeyCallback<Long> callback = new SqlInsertWithKeyCallback<Long>() {
		@Override
		public Long doInSqlInsertWithKeyClause(SQLInsertClause insert) {
			insert.set(a.launchedBy, launcherId);
			insert.set(a.launchedAt, launchedAt);
			insert.set(a.mailStatus, FlagCode.FALSE.code());
			insert.set(a.messageName, messageName);
			insert.set(a.scheduledAt, scheduledAt);
			insert.set(a.fromAddr, from);
			insert.set(a.subject, subject);
			insert.set(a.body, body);
			return insert.executeWithKey(Long.class);
		}
	};
	Long id = queryDslJdbcOperations.insertWithKey(a, callback);
	checkState(
			id != null,
			"failed to create QMailLog: launchedBy={0}, launchedAt={1}, mailStatus={2}, messageName={3}, scheduledAt={4}, fromAddr={5}, subject={6}, body={7}",
			launcherId, launchedAt, FlagCode.FALSE.code(), messageName, scheduledAt, from, subject, body);
	return id.longValue();
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:25,代码来源:MessageStoreImpl.java

示例5: createAsyncProcess

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
private long createAsyncProcess(final String launcherId, final String description, final AsyncType asyncType,
		final LocalDateTime dtm) {
	final QAsyncProcess a = new QAsyncProcess("a");
	SqlInsertWithKeyCallback<Long> callback = new SqlInsertWithKeyCallback<Long>() {
		@Override
		public Long doInSqlInsertWithKeyClause(SQLInsertClause insert) {
			insert.set(a.launchedBy, launcherId);
			insert.set(a.description, adjustSize(description, a.description));
			insert.set(a.asyncType, asyncType.code());
			insert.set(a.asyncStatus, AsyncStatus.LAUNCHING.code());
			insert.set(a.registeredAt, dtm);
			return insert.executeWithKey(Long.class);
		}
	};
	Long id = queryDslJdbcOperations.insertWithKey(a, callback);
	checkState(
			id != null,
			"failed to create QAsyncProcess: launchedBy={0}, description={1}, asyncType={2}, asyncStatus={3}, registeredAt={4}",
			launcherId, description, asyncType.code(), AsyncStatus.LAUNCHING.code(), dtm);
	return id.longValue();
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:22,代码来源:AsyncProcessStoreImpl.java

示例6: create

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Transactional
@Override
public Long create(BasicEx20Form form) {
	SQLInsertClause insert = qf.insert(et1);
	if (StringUtils.isNotEmpty(form.getText10())) {
		insert.set(et1.text10, form.getText10());
	}
	if (StringUtils.isNotEmpty(form.getText100())) {
		insert.set(et1.text100, form.getText100());
	}
	insert.set(et1.int64, form.getInt64());
	insert.set(et1.decimal1, form.getDecimal1());
	insert.set(et1.decimal3, form.getDecimal3());
	insert.set(et1.dt, form.getDt());
	insert.set(et1.tm, form.getTm());
	insert.set(et1.dtm, form.getDtm());
	return insert.executeWithKey(et1.id);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:BasicEx20ServiceImpl.java

示例7: create

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Transactional
@Override
public Long create(BasicEx10Form form) {
	SQLInsertClause insert = qf.insert(et1);
	if (StringUtils.isNotEmpty(form.getText10())) {
		insert.set(et1.text10, form.getText10());
	}
	if (StringUtils.isNotEmpty(form.getText100())) {
		insert.set(et1.text100, form.getText100());
	}
	insert.set(et1.int64, form.getInt64());
	insert.set(et1.decimal1, form.getDecimal1());
	insert.set(et1.decimal3, form.getDecimal3());
	insert.set(et1.dt, form.getDt());
	insert.set(et1.tm, form.getTm());
	insert.set(et1.dtm, form.getDtm());
	return insert.executeWithKey(et1.id);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:BasicEx10ServiceImpl.java

示例8: testSaveAndLoad

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Test
public void testSaveAndLoad() {

	LocalDate orig = LocalDate.now();
	SQLInsertClause insert = queryFactory.insert(vd);
	insert.set(vd.dt, orig);
	long count = insert.execute();
	assertEquals(1L, count);

	SQLQuery query = queryFactory.from(vd);
	LocalDate result = query.uniqueResult(vd.dt);
	assertEquals(orig, result);

	assertEquals(
			Integer.valueOf(1),
			jdbcOperations.queryForObject("SELECT COUNT(*) FROM verify_datetime WHERE dt=?", Integer.class,
					orig.toString("yyyy-MM-dd")));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:LocalDateTypeTest.java

示例9: testSaveAndLoad_plus1d

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Test
public void testSaveAndLoad_plus1d() {

	LocalDate orig = LocalDate.now().plusDays(1);
	SQLInsertClause insert = queryFactory.insert(vd);
	insert.set(vd.dt, orig);
	long count = insert.execute();
	assertEquals(1L, count);

	SQLQuery query = queryFactory.from(vd);
	LocalDate result = query.uniqueResult(vd.dt);
	assertEquals(orig, result);

	assertEquals(
			Integer.valueOf(1),
			jdbcOperations.queryForObject("SELECT COUNT(*) FROM verify_datetime WHERE dt=?", Integer.class,
					orig.toString("yyyy-MM-dd")));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:LocalDateTypeTest.java

示例10: testSaveAndLoad

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Test
public void testSaveAndLoad() {

	LocalDateTime orig = LocalDateTime.now();
	SQLInsertClause insert = queryFactory.insert(vd);
	insert.set(vd.dtm, orig);
	long count = insert.execute();
	assertEquals(1L, count);

	SQLQuery query = queryFactory.from(vd);
	LocalDateTime result = query.uniqueResult(vd.dtm);
	assertEquals(orig, result);

	assertEquals(
			Integer.valueOf(1),
			jdbcOperations.queryForObject("SELECT COUNT(*) FROM verify_datetime WHERE dtm=?", Integer.class,
					orig.toString("yyyy-MM-dd HH:mm:ss.SSS")));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:LocalDateTimeTypeTest.java

示例11: testSaveAndLoad_plus1d

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Test
public void testSaveAndLoad_plus1d() {

	LocalDateTime orig = LocalDateTime.now().plusDays(1);
	SQLInsertClause insert = queryFactory.insert(vd);
	insert.set(vd.dtm, orig);
	long count = insert.execute();
	assertEquals(1L, count);

	SQLQuery query = queryFactory.from(vd);
	LocalDateTime result = query.uniqueResult(vd.dtm);
	assertEquals(orig, result);

	assertEquals(
			Integer.valueOf(1),
			jdbcOperations.queryForObject("SELECT COUNT(*) FROM verify_datetime WHERE dtm=?", Integer.class,
					orig.toString("yyyy-MM-dd HH:mm:ss.SSS")));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:LocalDateTimeTypeTest.java

示例12: testSaveAndLoad

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Test
public void testSaveAndLoad() {

	LocalTime orig = LocalTime.now();
	SQLInsertClause insert = queryFactory.insert(vd);
	insert.set(vd.tm, orig);
	long count = insert.execute();
	assertEquals(1L, count);

	SQLQuery query = queryFactory.from(vd);
	LocalTime result = query.uniqueResult(vd.tm);
	assertEquals(orig, result);

	assertEquals(
			Integer.valueOf(1),
			jdbcOperations.queryForObject("SELECT COUNT(*) FROM verify_datetime WHERE tm=?", Integer.class,
					orig.toString("HH:mm:ss.SSS")));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:LocalTimeTypeTest.java

示例13: testSaveAndLoad_plus1h

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Test
public void testSaveAndLoad_plus1h() {

	LocalTime orig = LocalTime.now().plusHours(1);
	SQLInsertClause insert = queryFactory.insert(vd);
	insert.set(vd.tm, orig);
	long count = insert.execute();
	assertEquals(1L, count);

	SQLQuery query = queryFactory.from(vd);
	LocalTime result = query.uniqueResult(vd.tm);
	assertEquals(orig, result);

	assertEquals(
			Integer.valueOf(1),
			jdbcOperations.queryForObject("SELECT COUNT(*) FROM verify_datetime WHERE tm=?", Integer.class,
					orig.toString("HH:mm:ss.SSS")));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:LocalTimeTypeTest.java

示例14: createMailLog

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
private long createMailLog(String launcherId, LocalDateTime launchedAt, String messageName,
		LocalDateTime scheduledAt, String from, String replyTo, String subject, String body) {
	SQLInsertClause insert = queryFactory.insert(ml);
	insert.set(ml.launchedBy, launcherId);
	insert.set(ml.launchedAt, launchedAt);
	insert.set(ml.mailStatus, FlagCode.FALSE.code());
	insert.set(ml.messageName, messageName);
	insert.set(ml.scheduledAt, scheduledAt);
	insert.set(ml.fromAddr, from);
	insert.set(ml.replyToAddr, replyTo);
	insert.set(ml.subject, subject);
	insert.set(ml.body, body);
	Long id = insert.executeWithKey(Long.class);
	checkState(
			id != null,
			"failed to create %s: launchedBy=%s, launchedAt=%s, mailStatus=%s, messageName=%s, scheduledAt=%s, fromAddr=%s, replyToAddr=%s, subject=%s, body=%s",
			ml.getTableName(), launcherId, launchedAt, FlagCode.FALSE.code(), messageName, scheduledAt, from,
			replyTo, subject, body);
	return id.longValue();
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:21,代码来源:MessageStoreImpl.java

示例15: createCommand

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Transactional(value = "jtaTransactionManager", propagation = REQUIRES_NEW)
public long createCommand(String launcherId, LocalDateTime dtm, String description, String command, String... args) {

	long asyncId = createAsyncProcess(launcherId, description, AsyncType.COMMAND, dtm);

	SQLInsertClause insert = queryFactory.insert(apc);
	insert.set(apc.asyncId, asyncId);
	insert.set(apc.command, adjustSize(command, apc.command));
	long count = insert.execute();
	checkState(count == 1L, "failed to create %s: asyncId=%s, command=%s", apc.getTableName(), asyncId, command);

	for (String arg : args) {
		long c = queryFactory.insert(apca).set(apca.asyncId, asyncId)
				.set(apca.argument, adjustSize(arg, apca.argument)).execute();
		checkState(c == 1L, "failed to create %s: asyncId=%s, arg=%s", apca.getTableName(), asyncId, arg);
	}

	return asyncId;
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:20,代码来源:AsyncProcessStoreImpl.java


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