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

Java SQLInsertClause类代码示例

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

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



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


示例16: 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 QMailLog: launchedBy=%s, launchedAt=%s, mailStatus=%s, messageName=%s, scheduledAt=%s, fromAddr=%s, replyToAddr=%s, subject=%s, body=%s",
			launcherId, launchedAt, FlagCode.FALSE.code(), messageName, scheduledAt, from, replyTo, subject, body);
	return id.longValue();
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:20,代码来源:MessageStoreImpl.java


示例17: 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 QAsyncProcessCommand: asyncId=%s, command=%s", 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 QAsyncProcessCommandArg: asyncId=%s, arg=%s", asyncId, arg);
	}

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


示例18: finishCommand

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
@Transactional(propagation = REQUIRES_NEW)
@Override
public void finishCommand(long asyncId, LocalDateTime dtm, AsyncStatus status, CommandResult result) {

	finishAsyncProcess(asyncId, dtm, status);

	SQLInsertClause insert = queryFactory.insert(apcr);
	insert.set(apcr.asyncId, asyncId);
	insert.set(apcr.exitValue, result.getExitValue());
	insert.set(apcr.stdout, adjustSize(result.getStdout(), apcr.stdout));
	insert.set(apcr.stderr, adjustSize(result.getStderr(), apcr.stderr));
	long count = insert.execute();
	checkState(count == 1L,
			"failed to create QAsyncProcessCommandResult: asyncId=%s, exitValue=%s, stdout=%s, stderr=%s", asyncId,
			result.getExitValue(), result.getStdout(), result.getStderr());
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:17,代码来源:AsyncProcessStoreImpl.java


示例19: executePerformInsert

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
private Object executePerformInsert(PerformInsert query) {
	SQLInsertClause insert = insert(query.getEntity());
	
	Iterator<PerformInsertBatch> batchItr = query.getBatches().iterator();		
	
	processInsertBatch(insert, batchItr.next());
	
	if(batchItr.hasNext()) {
		insert.addBatch();
		
		while(batchItr.hasNext()) {
			processInsertBatch(insert, batchItr.next());
			insert.addBatch();
		}
	}
	
	Optional<Path<?>> key = query.getKey();
	
	if(key.isPresent()) {			
		return toTypedList(insert, key.get());
	} else {
		return insert.execute();
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:25,代码来源:PublisherTransaction.java


示例20: useQueryDslInsert

import com.mysema.query.sql.dml.SQLInsertClause; //导入依赖的package包/类
/**
 * 使用QueryDsl新增
 */
public int useQueryDslInsert(final Customer customer){
	
	final QCustomer qCustomer = new QCustomer("customer");
	
	int returnVal = queryDslJdbcTemplate.insertWithKey(qCustomer, new SqlInsertWithKeyCallback<Integer>() {

		@Override
		public Integer doInSqlInsertWithKeyClause(SQLInsertClause insert)
				throws SQLException {
			return insert.columns(qCustomer.name,qCustomer.age).values(customer.getName(),customer.getAge()).executeWithKey(qCustomer.custId);
		}
	});
	
	return returnVal;
	
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:20,代码来源:JdbcCustomerDAO.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java CTBorder类代码示例发布时间:2022-05-22
下一篇:
Java EntitySquid类代码示例发布时间: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