本文整理汇总了Java中com.mysema.query.sql.SQLQuery类的典型用法代码示例。如果您正苦于以下问题:Java SQLQuery类的具体用法?Java SQLQuery怎么用?Java SQLQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLQuery类属于com.mysema.query.sql包,在下文中一共展示了SQLQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setBalance
import com.mysema.query.sql.SQLQuery; //导入依赖的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
示例2: getTransactions
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
public List<Transaction> getTransactions(long limit) {
QTransactions t = QTransactions.transactions;
QPlayers p = QPlayers.players;
SQLQuery query = DatabaseManager.getInstance().getNewQuery();
List<Tuple> list = query
.from(t)
.join(p)
.on(t.id.eq(p.id))
.orderBy(t.datetime.asc())
.limit(limit)
.list(p.uuid, t.datetime, t.description, t.amount);
return transformTuple(list);
}
开发者ID:DemonWav,项目名称:EctoTokens,代码行数:17,代码来源:TokensManager.java
示例3: getTransaction
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
public List<Transaction> getTransaction(long lowEnd, long highEnd) {
QTransactions t = QTransactions.transactions;
QPlayers p = QPlayers.players;
SQLQuery query = DatabaseManager.getInstance().getNewQuery();
List<Tuple> list = query
.from(t)
.join(p)
.on(p.id.eq(t.id))
.orderBy(t.datetime.asc())
.where(t.amount.between(lowEnd, highEnd))
.orderBy(t.datetime.asc())
.list(p.uuid, t.datetime, t.description, t.amount);
return transformTuple(list);
}
开发者ID:DemonWav,项目名称:EctoTokens,代码行数:18,代码来源:TokensManager.java
示例4: testMappingProjection
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void testMappingProjection()
throws Exception {
Connection conn = DbHelper.objectDb();
SQLQuery sqlquery = new SQLQuery(conn, new HSQLDBTemplates());
try {
List<DbObject> list =
sqlquery
.from(qTestDbObject)
.where(qTestDbObject.id.eq(1l))
.list(
new QueryDslMappingProjection<DbObject>(
DbObject.class,
qTestDbObject.id, qTestDbObject.name, qTestDbObject.email,
qTestDbObject.creationTime, qTestDbObject.typeName, qTestDbObject.typeOrdinal ));
assertEquals(1, list.size());
DbHelper.assertDbObjectMapping(list.get(0));
} finally {
conn.close();
}
}
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:26,代码来源:QueryDSLTest.java
示例5: downloadMain
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
private long downloadMain(QueryConfigurer commonClause, QueryConfigurer orderByClause, Consumer consumer,
Limiter limiter, Expression<?>... expressions) throws LimiterException, IOException {
ResultSetExtractor<Long> extractor = new ExtractorResultSetExtractor(consumer, limiter);
limiter.start();
try {
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query = commonClause.configure(query);
query = orderByClause.configure(query);
return queryDslJdbcOperations.queryForObject(query, extractor, expressions);
} catch (IllegalStateException ex) {
throw (IOException) ex.getCause();
} finally {
limiter.stop();
}
}
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:20,代码来源:QueryDslSupportImpl.java
示例6: testMyBatisToQuerydsl
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void testMyBatisToQuerydsl() {
LocalDateTime ldt = LocalDateTime.now();
LocalDate ld = LocalDate.now();
LocalTime lt = LocalTime.now();
ConversionTest record = new ConversionTest();
record.setJodaDatetime(ldt);
record.setJodaDate(ld);
record.setJodaTime(lt);
int count = mapper.insert(record);
assertEquals(1, count);
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(ct);
Tuple tuple = queryDslJdbcOperations.queryForObject(query,
new QTuple(ct.jodaDatetime, ct.jodaDate, ct.jodaTime));
assertEquals(ldt, tuple.get(ct.jodaDatetime));
assertEquals(ld, tuple.get(ct.jodaDate));
assertEquals(lt, tuple.get(ct.jodaTime));
}
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:23,代码来源:InteropTest.java
示例7: testSaveAndLoad
import com.mysema.query.sql.SQLQuery; //导入依赖的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
示例8: testSaveAndLoad_plus1d
import com.mysema.query.sql.SQLQuery; //导入依赖的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
示例9: findEventById
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Override
public DirectedEventRow findEventById(String id) {
int idInt = FastNumberUtils.parseIntWithCheck(id);
WalkerTransactionPair100 results = null;
QWalkerTransactionPair100 t = new QWalkerTransactionPair100("t");
Connection conn;
try {
conn = getConnection();
SQLQuery sq = from(conn, t).where(t.pairId.eq(idInt));
results = sq.singleResult(t);
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return funnel.from(results);
}
开发者ID:Sotera,项目名称:graphene-walker,代码行数:18,代码来源:TransactionDAOSQLImpl.java
示例10: findByQuery
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Override
public List<WalkerIdentifierType100> findByQuery(StringQuery q)
throws Exception {
List<WalkerIdentifierType100> results = new ArrayList<WalkerIdentifierType100>();
QWalkerIdentifierType100 t = new QWalkerIdentifierType100("t");
Connection conn;
conn = getConnection();
SQLQuery sq = buildQuery(q, t, conn);
sq = setOffsetAndLimit(q, sq);
if (sq != null) {
sq = sq.orderBy(t.idtypeId.asc());
results = sq.list(t);
}
conn.close();
if (results != null) {
logger.debug("Returning " + results.size() + " entries");
}
return results;
}
开发者ID:Sotera,项目名称:graphene-walker,代码行数:21,代码来源:IdTypeDAOSQLImpl.java
示例11: getAllFast
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
/**
* Uses the full bean, but optimized SQL
*
* @param offset
* @param limit
* @return
* @throws Exception
*/
private List<WalkerEntityref100> getAllFast(long offset, long limit)
throws Exception {
Connection conn = getConnection();
QWalkerEntityref100 t = new QWalkerEntityref100("t");
SQLQuery sq = from(conn, t);
/*
* XXX: Note that we are treating offset and limit differently than
* usual. When using it in a between statement, we need to use
* limit+offset
*/
sq = sq.where(t.entityrefId.between(offset, limit + offset).and(
t.idtypeId.notIn(idTypeDAO.getSkipTypes())));
/*
* Note that we are not sorting the elements here, in order to speed
* things up.
*/
logger.debug("Query: " + sq.toString());
List<WalkerEntityref100> results = sq.list(t);
conn.close();
return results;
}
开发者ID:Sotera,项目名称:graphene-walker,代码行数:33,代码来源:EntityRefDAODiskImpl.java
示例12: QAuthor
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec020101_カラムを絞って照会する() {
QAuthor a = new QAuthor("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
a.loginId, a.name));
for (Tuple tuple : list) {
Long valId = tuple.get(a.id);
String valLoginId = tuple.get(a.loginId);
String valName = tuple.get(a.name);
LocalDateTime valUpdatedAt = tuple.get(a.updatedAt);
LocalDateTime valCreatedAt = tuple.get(a.createdAt);
Integer valLockVersion = tuple.get(a.lockVersion);
Integer valDeletedFlg = tuple.get(a.deletedFlg);
out.println(format(
"{0}: loginId={1}, name={2}, updatedAt={3}, createdAt={4}, lockVersion={5}, deletedFlg={6}",
valId, valLoginId, valName, valUpdatedAt, valCreatedAt,
valLockVersion, valDeletedFlg));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:24,代码来源:SelectClauseTest.java
示例13: testSaveAndLoad_plus1d
import com.mysema.query.sql.SQLQuery; //导入依赖的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
示例14: QTodo
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec020501_CASE式を指定する_単純CASE式() {
/* 抽出条件を組み立てる。 */
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
/* CASE式を組立てる。 */
Expression<String> doneDesc = a.doneFlg.when(0).then("未実施").when(1)
.then("実施済").otherwise("不定");
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
a.doneFlg, doneDesc));
/* クエリの結果を表示する。 */
for (Tuple tuple : list) {
Long valId = tuple.get(a.id);
Integer valDoneFlg = tuple.get(a.doneFlg);
String valDoneDesc = tuple.get(doneDesc);
out.println(format("{0}: doneFlg={1}, doneDesc(CASE)={2}", valId,
valDoneFlg, valDoneDesc));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:26,代码来源:SelectClauseTest.java
示例15: sec0501_GROUPBY
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec0501_GROUPBY() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:21,代码来源:AdvancedUsageTest.java
示例16: testSaveAndLoad_plus1h
import com.mysema.query.sql.SQLQuery; //导入依赖的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
示例17: sec0503_ORDERBY
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec0503_ORDERBY() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
query.orderBy(a.id.count().asc());
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:22,代码来源:AdvancedUsageTest.java
示例18: QTodo
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec040101_抽出条件の記述方法_単一条件() {
/* 抽出条件を組み立てる。 */
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a).where(a.deletedFlg.eq(0));
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id, a.postedAt, a.dueDt, a.doneFlg,
a.doneAt));
/* クエリの結果を表示する。 */
for (Tuple tuple : list) {
Long valId = tuple.get(a.id);
LocalDateTime valPostedAt = tuple.get(a.postedAt);
LocalDate valDueDt = tuple.get(a.dueDt);
Integer valDoneFlg = tuple.get(a.doneFlg);
LocalDateTime valDoneAt = tuple.get(a.doneAt);
out.println(format("{0}: postedAt={1}, dueDt={2}, doneFlg={3}, doneAt={4}", valId, valPostedAt, valDueDt,
valDoneFlg, valDoneAt));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:24,代码来源:WhereClauseTest.java
示例19: QTodo
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec030201_複数表を指定して結合する_内部結合() {
/* 抽出条件を組み立てる。 */
QTodo a = new QTodo("a");
QAuthor b = new QAuthor("b");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a).join(b).on(b.loginId.eq(a.postedBy), b.deletedFlg.eq(0));
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
a.postedBy, b.name));
/* クエリの結果を表示する。 */
for (Tuple tuple : list) {
Long valId = tuple.get(a.id);
String valPostedBy = tuple.get(a.postedBy);
String valPosterName = tuple.get(b.name);
System.out.println(MessageFormat.format(
"{0}: postedBy={1}, posterName={2}", valId, valPostedBy,
valPosterName));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:24,代码来源:FromClauseTest.java
示例20: QAuthor
import com.mysema.query.sql.SQLQuery; //导入依赖的package包/类
@Test
public void sec0102_Beanとして取出す_QBean() {
/* 抽出条件を組み立てる。 */
QAuthor a = new QAuthor("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Author> list = queryDslJdbcOperations.query(query, new QBean<Author>(Author.class, a.all()));
/* クエリの結果を表示する。 */
for (Author entity : list) {
Long valId = entity.getId();
String valLoginId = entity.getLoginId();
String valName = entity.getName();
LocalDateTime valUpdatedAt = entity.getUpdatedAt();
LocalDateTime valCreatedAt = entity.getCreatedAt();
Integer valLockVersion = entity.getLockVersion();
Integer valDeletedFlg = entity.getDeletedFlg();
out.println(format(
"{0}: loginId={1}, name={2}, updatedAt={3}, createdAt={4}, lockVersion={5}, deletedFlg={6}", valId,
valLoginId, valName, valUpdatedAt, valCreatedAt, valLockVersion, valDeletedFlg));
}
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:26,代码来源:BasicUsageTest.java
注:本文中的com.mysema.query.sql.SQLQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论