本文整理汇总了Java中com.mysema.query.Tuple类的典型用法代码示例。如果您正苦于以下问题:Java Tuple类的具体用法?Java Tuple怎么用?Java Tuple使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tuple类属于com.mysema.query包,在下文中一共展示了Tuple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addParticipant
import com.mysema.query.Tuple; //导入依赖的package包/类
private void addParticipant(@Nonnull PullRequest pullRequest, @Nonnull final Tuple tuple)
{
final String username = tuple.get(participantMapping.USERNAME);
final Boolean approved = tuple.get(participantMapping.APPROVED);
final String role = tuple.get(participantMapping.ROLE);
// We are left joining so only include the participant if it is available
if (username != null || approved != null || role != null)
{
Participant participant = new Participant(username,
approved == null ? false : approved, role);
if (pullRequest.getParticipants() == null)
{
pullRequest.setParticipants(new ArrayList<Participant>());
}
if (!pullRequest.getParticipants().contains(participant))
{
pullRequest.getParticipants().add(participant);
}
}
}
示例2: getTransactions
import com.mysema.query.Tuple; //导入依赖的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);
}
示例3: getTransaction
import com.mysema.query.Tuple; //导入依赖的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);
}
示例4: getAll
import com.mysema.query.Tuple; //导入依赖的package包/类
@Override
public List<WalkerEntityref100> getAll(long offset, long limit)
throws Exception {
List<Tuple> tupleResults = getAllTuples(offset, limit);
List<WalkerEntityref100> results = new ArrayList<WalkerEntityref100>(
tupleResults.size());
// Funnel the tuple into the bean, but unset properties will stay null
// and not take up space.
QWalkerEntityref100 t = new QWalkerEntityref100("t");
for (Tuple tuple : tupleResults) {
WalkerEntityref100 k = new WalkerEntityref100();
k.setAccountnumber(tuple.get(t.accountnumber));
k.setCustomernumber(tuple.get(t.customernumber));
k.setIdentifier(tuple.get(t.identifier));
k.setIdtypeId(tuple.get(t.idtypeId));
results.add(k);
}
return results;
}
示例5: getAll
import com.mysema.query.Tuple; //导入依赖的package包/类
@Override
public List<WalkerEntityref100> getAll(long offset, long limit)
throws Exception {
List<Tuple> tupleResults = getAllTuples(offset, limit);
List<WalkerEntityref100> results = new ArrayList<WalkerEntityref100>(
tupleResults.size());
// Funnel the tuple into the bean, but unset properties will stay null
// and not take up space.
QWalkerEntityref100 t = new QWalkerEntityref100("t");
for (Tuple tuple : tupleResults) {
WalkerEntityref100 k = new WalkerEntityref100();
k.setAccountnumber(tuple.get(t.accountnumber));
k.setCustomernumber(tuple.get(t.accountnumber));
k.setIdentifier(tuple.get(t.identifier));
k.setIdtypeId(tuple.get(t.idtypeId));
results.add(k);
}
return results;
}
示例6: QAuthor
import com.mysema.query.Tuple; //导入依赖的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));
}
}
示例7: QTodo
import com.mysema.query.Tuple; //导入依赖的package包/类
@Test
public void sec020408_カラムに対する関数適用_集約関数() {
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));
}
}
示例8: sec0501_GROUPBY
import com.mysema.query.Tuple; //导入依赖的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));
}
}
示例9: sec0502_HAVING
import com.mysema.query.Tuple; //导入依赖的package包/类
@Test
public void sec0502_HAVING() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
query.having(a.id.count().gt(1), a.postedAt.max().lt(new LocalDateTime(2015, 2, 1, 0, 0)));
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));
}
}
示例10: createSuperTuple
import com.mysema.query.Tuple; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void createSuperTuple() {
id = (Expression<Integer>)mock(Expression.class);
stringValue = (Expression<String>)mock(Expression.class);
doubleValue = (Expression<Double>)mock(Expression.class);
Tuple parentTuple = mock(Tuple.class);
when(parentTuple.size()).thenReturn(2);
when(parentTuple.toArray()).thenReturn(new Object[]{0, "Hello, world!"});
when(parentTuple.get(id)).thenReturn(0);
when(parentTuple.get(stringValue)).thenReturn("Hello, world!");
when(parentTuple.get(0, Integer.class)).thenReturn(0);
when(parentTuple.get(1, String.class)).thenReturn("Hello, world!");
Tuple tuple = mock(Tuple.class);
when(tuple.size()).thenReturn(2);
when(tuple.toArray()).thenReturn(new Object[]{0, 42.0});
when(tuple.get(id)).thenReturn(0);
when(tuple.get(doubleValue)).thenReturn(42.0);
when(tuple.get(0, Integer.class)).thenReturn(0);
when(tuple.get(1, Double.class)).thenReturn(42.0);
superTuple = new JoinedTuple(parentTuple, tuple);
}
示例11: QTodo
import com.mysema.query.Tuple; //导入依赖的package包/类
@Test
public void sec040102_抽出条件の記述方法_複合条件() {
/* 抽出条件を組み立てる。 */
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a).where(a.deletedFlg.eq(0)).where(a.doneFlg.eq(1));
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
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));
}
}
示例12: QTodo
import com.mysema.query.Tuple; //导入依赖的package包/类
@Test
public void sec030202_複数表を指定して結合する_左外部結合() {
/* 抽出条件を組み立てる。 */
QTodo a = new QTodo("a");
QAuthor b = new QAuthor("b");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a).leftJoin(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));
}
}
示例13: QAuthor
import com.mysema.query.Tuple; //导入依赖的package包/类
@Test
public void sec0101_Tupleとして取出す() {
/* 抽出条件を組み立てる。 */
QAuthor a = new QAuthor("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.all()));
/* クエリの結果を表示する。 */
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));
}
}
示例14: findById
import com.mysema.query.Tuple; //导入依赖的package包/类
@Transactional(readOnly = true)
@Override
public SqlClauseForm findById(int id) {
Tuple tuple = queryFactory
.from(c)
.where(c.id.eq(id))
.uniqueResult(c.databaseName, c.selectClause, c.fromClause, c.whereClause, c.groupByClause,
c.havingClause, c.orderByClause, c.paramMap, c.lockVersion);
if (tuple == null) {
return null;
}
SqlClauseForm form = new SqlClauseForm();
form.setDatabaseName(tuple.get(c.databaseName));
form.setSelect(tuple.get(c.selectClause));
form.setFrom(tuple.get(c.fromClause));
form.setWhere(tuple.get(c.whereClause));
form.setGroupBy(tuple.get(c.groupByClause));
form.setHaving(tuple.get(c.havingClause));
form.setOrderBy(tuple.get(c.orderByClause));
form.setParamMap(tuple.get(c.paramMap));
form.setLockVersion(tuple.get(c.lockVersion));
return form;
}
示例15: testExecute
import com.mysema.query.Tuple; //导入依赖的package包/类
@Test
public void testExecute() throws Exception {
assertTrue(query().from(dataSource).notExists());
CompletableFuture<Long> future = db.insert(dataSource)
.set(dataSource.identification, "id")
.set(dataSource.name, "name")
.execute();
Long affectedRows = future.get(2, TimeUnit.SECONDS);
assertNotNull(affectedRows);
assertEquals(new Long(1), affectedRows);
Tuple queryResult = query()
.from(dataSource)
.singleResult(
dataSource.identification,
dataSource.name);
assertNotNull(queryResult);
assertEquals("id", queryResult.get(dataSource.identification));
assertEquals("name", queryResult.get(dataSource.name));
}