本文整理汇总了Java中com.mysema.query.sql.SQLQuery.singleResult方法的典型用法代码示例。如果您正苦于以下问题:Java SQLQuery.singleResult方法的具体用法?Java SQLQuery.singleResult怎么用?Java SQLQuery.singleResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysema.query.sql.SQLQuery
的用法示例。
在下文中一共展示了SQLQuery.singleResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: getTemplate
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Transactional
@Override
public MailData getTemplate(String templateName) {
SQLQuery querya = queryFactory.from(mt);
querya.where(mt.templateName.eq(templateName));
Tuple templ = querya.singleResult(mt.id, mt.fromAddr, mt.replyToAddr, mt.subject, mt.body);
SQLQuery queryb = queryFactory.from(mtr);
queryb.where(mtr.templateId.eq(templ.get(mt.id)));
List<Tuple> templAddr = queryb.list(mtr.rcptType, mtr.rcptAddr);
List<String> toAddr = new ArrayList<>();
List<String> ccAddr = new ArrayList<>();
List<String> bccAddr = new ArrayList<>();
for (Tuple addr : templAddr) {
RcptType type = RcptType.valueOf(addr.get(mtr.rcptType));
if (type == RcptType.TO) {
toAddr.add(addr.get(mtr.rcptAddr));
}
if (type == RcptType.CC) {
ccAddr.add(addr.get(mtr.rcptAddr));
}
if (type == RcptType.BCC) {
bccAddr.add(addr.get(mtr.rcptAddr));
}
}
MailData template = new MailData();
template.setFromAddr(templ.get(mt.fromAddr));
template.setToAddr(toAddr);
template.setCcAddr(ccAddr);
template.setBccAddr(bccAddr);
template.setReplyToAddr(templ.get(mt.replyToAddr));
template.setSubject(templ.get(mt.subject));
template.setBody(templ.get(mt.body));
return template;
}
示例3: findByValue
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Transactional(readOnly = true)
@Override
public CodeEntry findByValue(String codeName, String value) {
SQLQuery query = queryFactory.from(qcm);
query.where(qcm.name.eq(codeName), qcm.value.eq(value));
return query.singleResult(new QBean<>(CodeEntry.class, qcm.value, qcm.label, qcm.sortOrder));
}
示例4: getNumberOfWorkday
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Transactional
@Override
public int getNumberOfWorkday(String name, LocalDate from, LocalDate to) {
SQLQuery query = queryFactory.from(h0);
query.where(h0.name.eq(name), h0.dt.between(from, to));
long count = query.singleResult(h0.dt.count());
return Days.daysBetween(from, to).getDays() + 1 - (int) count;
}
示例5: getMessage
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Override
public SimpleMailMessage getMessage(long messageId) {
SQLQuery querya = queryFactory.from(ml).forUpdate();
querya.where(ml.id.eq(messageId), ml.mailStatus.eq(FlagCode.FALSE.code()));
Tuple maillog = querya.singleResult(ml.fromAddr, ml.replyToAddr, ml.subject, ml.body);
if (maillog == null) {
return null;
}
SQLQuery queryb = queryFactory.from(mr);
queryb.where(mr.mailId.eq(messageId));
queryb.orderBy(mr.id.asc());
List<Tuple> mailrcpt = queryb.list(mr.rcptType, mr.rcptAddr);
if (mailrcpt.isEmpty()) {
return null;
}
List<String> to = new ArrayList<>();
List<String> cc = new ArrayList<>();
List<String> bcc = new ArrayList<>();
for (Tuple rcpt : mailrcpt) {
RcptType type = RcptType.valueOf(rcpt.get(mr.rcptType));
if (type == RcptType.TO) {
to.add(rcpt.get(mr.rcptAddr));
}
if (type == RcptType.CC) {
cc.add(rcpt.get(mr.rcptAddr));
}
if (type == RcptType.BCC) {
bcc.add(rcpt.get(mr.rcptAddr));
}
}
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(to.toArray(new String[to.size()]));
msg.setCc(cc.toArray(new String[cc.size()]));
msg.setBcc(bcc.toArray(new String[bcc.size()]));
msg.setFrom(maillog.get(ml.fromAddr));
msg.setReplyTo(maillog.get(ml.replyToAddr));
msg.setSubject(maillog.get(ml.subject));
msg.setText(maillog.get(ml.body));
return msg;
}
示例6: testWithServiceStructure
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void testWithServiceStructure() throws Exception {
SQLQuery structureQuery =
QServiceStructure.withServiceStructure(query(), AbstractQuery.parent, AbstractQuery.child)
.from(serviceStructure);
assertFalse(structureQuery.exists());
int rootId = insert(genericLayer)
.set(genericLayer.identification, "service")
.set(genericLayer.name, "service-name")
.executeWithKey(genericLayer.id);
int layerId = insert(genericLayer)
.set(genericLayer.identification, "layer")
.set(genericLayer.name, "layer-name")
.executeWithKey(genericLayer.id);
insert(leafLayer)
.set(leafLayer.genericLayerId, layerId)
.set(leafLayer.datasetId, vectorDatasetId)
.executeWithKey(leafLayer.id);
insert(layerStructure)
.set(layerStructure.childLayerId, layerId)
.set(layerStructure.parentLayerId, rootId)
.set(layerStructure.layerOrder, 0)
.execute();
insert(service)
.set(service.genericLayerId, rootId)
.set(service.wfsMetadataFileIdentification, UUID.randomUUID().toString())
.set(service.wmsMetadataFileIdentification, UUID.randomUUID().toString())
.execute();
Tuple result = structureQuery
.singleResult(
serviceStructure.serviceIdentification,
serviceStructure.parentLayerIdentification,
serviceStructure.childLayerIdentification,
serviceStructure.datasetId);
assertNotNull(result);
assertEquals("service", result.get(serviceStructure.serviceIdentification));
assertEquals("service", result.get(serviceStructure.parentLayerIdentification));
assertEquals("layer", result.get(serviceStructure.childLayerIdentification));
assertEquals(Integer.valueOf(vectorDatasetId), result.get(serviceStructure.datasetId));
}