本文整理了Java中org.hibernate.Query.setLong
方法的一些代码示例,展示了Query.setLong
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setLong
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setLong
[英]Bind a positional long-valued parameter.
[中]绑定位置长值参数。
代码示例来源:origin: gocd/gocd
Modification findModificationWithRevision(Session session, long materialId, String revision) {
Modification modification;
String key = cacheKeyForModificationWithRevision(materialId, revision);
modification = (Modification) goCache.get(key);
if (modification == null) {
synchronized (key) {
modification = (Modification) goCache.get(key);
if (modification == null) {
Query query = session.createQuery("FROM Modification WHERE materialId = ? and revision = ? ORDER BY id DESC");
query.setLong(0, materialId);
query.setString(1, revision);
modification = (Modification) query.uniqueResult();
goCache.put(key, modification);
}
}
}
return modification;
}
代码示例来源:origin: gocd/gocd
public Long getTotalModificationsFor(final MaterialInstance materialInstance) {
String key = materialModificationCountKey(materialInstance);
Long totalCount = (Long) goCache.get(key);
if (totalCount == null || totalCount == 0) {
synchronized (key) {
totalCount = (Long) goCache.get(key);
if (totalCount == null || totalCount == 0) {
totalCount = (Long) getHibernateTemplate().execute((HibernateCallback) session -> {
Query q = session.createQuery("select count(*) FROM Modification WHERE materialId = ?");
q.setLong(0, materialInstance.getId());
return q.uniqueResult();
});
goCache.put(key, totalCount);
}
}
}
return totalCount;
}
代码示例来源:origin: gocd/gocd
public Modifications getModificationsFor(final MaterialInstance materialInstance, final Pagination pagination) {
String key = materialModificationsWithPaginationKey(materialInstance);
String subKey = materialModificationsWithPaginationSubKey(pagination);
Modifications modifications = (Modifications) goCache.get(key, subKey);
if (modifications == null) {
synchronized (key) {
modifications = (Modifications) goCache.get(key, subKey);
if (modifications == null) {
List<Modification> modificationsList = (List<Modification>) getHibernateTemplate().execute((HibernateCallback) session -> {
Query q = session.createQuery("FROM Modification WHERE materialId = ? ORDER BY id DESC");
q.setFirstResult(pagination.getOffset());
q.setMaxResults(pagination.getPageSize());
q.setLong(0, materialInstance.getId());
return q.list();
});
if (!modificationsList.isEmpty()) {
modifications = new Modifications(modificationsList);
goCache.put(key, subKey, modifications);
}
}
}
}
return modifications;
}
代码示例来源:origin: sakaiproject/sakai
protected List getCountedStudentGradeRecords(final Long gradebookId, final String studentId) throws HibernateException {
return getSessionFactory().getCurrentSession().createQuery(
"select agr from AssignmentGradeRecord as agr, GradebookAssignment as asn where agr.studentId = :studentid and agr.gradableObject = asn and asn.removed is false and asn.notCounted is false and asn.gradebook.id = :gradebookid and asn.ungraded is false")
.setString("studentid", studentId)
.setLong("gradebookid", gradebookId)
.list();
}
代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate
@SuppressWarnings("unchecked")
public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
entering("ProcessInstanceDaoImpl.getActivityRecoveries");
List<ActivityRecoveryDAO> results = new ArrayList<ActivityRecoveryDAO>();
Query qry = getSession().createQuery(QRY_RECOVERIES);
qry.setLong(0, _instance.getId());
Iterator iter = qry.iterate();
while (iter.hasNext())
results.add(new ActivityRecoveryDaoImpl(_sm, (HActivityRecovery) iter.next()));
Hibernate.close(iter);
return results;
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
public List calculateAverageTimeByNode(long processDefinitionId, long minumumDurationMillis) {
try {
List tuples = session.getNamedQuery("GraphSession.calculateAverageTimeByNode")
.setLong("processDefinitionId", processDefinitionId)
.setDouble("minimumDuration", minumumDurationMillis)
.list();
if (tuples.isEmpty()) return Collections.EMPTY_LIST;
List results = new ArrayList();
for (Iterator i = tuples.iterator(); i.hasNext();) {
Object[] values = (Object[]) i.next();
AverageNodeTimeEntry entry = new AverageNodeTimeEntry();
entry.setNodeId(((Number) values[0]).longValue());
entry.setNodeName((String) values[1]);
entry.setCount(((Number) values[2]).intValue());
entry.setAverageDuration(((Number) values[3]).longValue());
entry.setMinDuration(((Number) values[4]).longValue());
entry.setMaxDuration(((Number) values[5]).longValue());
results.add(entry);
}
return results;
}
catch (HibernateException e) {
handle(e);
throw new JbpmPersistenceException("could not calculate average time by node "
+ "for process definition " + processDefinitionId, e);
}
}
代码示例来源:origin: sakaiproject/sakai
public Integer getCountItemFacades(final Long questionPoolId) {
final HibernateCallback<Number> hcb = session -> {
Query q = session.createQuery("select count(ab) from ItemData ab, QuestionPoolItemData qpi where ab.itemId = qpi.itemId and qpi.questionPoolId = :id");
q.setLong("id", questionPoolId);
q.setCacheable(true);
return (Number) q.uniqueResult();
};
return getHibernateTemplate().execute(hcb).intValue();
}
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
@SuppressWarnings("unchecked")
public List<Long> getTaskInstancesWaitingTimeOfUser(final String username, final Date since, final Date until) {
final Query query = getSession().getNamedQuery("getTaskInstancesWaitingTimeOfUser");
query.setLong("since", since.getTime());
query.setLong("until", until.getTime());
query.setString("userId", username);
return formatList(query.list());
}
代码示例来源:origin: hibernate/hibernate-orm
queryWithCollection.setLong("id", jboss.getId() );
list = queryWithCollection.list();
assertEquals(list.size(),1);
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
public UserContact getContactById(long id) {
return (UserContact) session()
.createQuery("from UserContact u where u.id = ?")
.setCacheable(true)
.setLong(0, id)
.uniqueResult();
}
}
代码示例来源:origin: org.sakaiproject.edu-services.gradebook/gradebook-service-impl
protected List getCountedStudentGradeRecords(Long gradebookId, String studentId) throws HibernateException {
return getSessionFactory().getCurrentSession().createQuery(
"select agr from AssignmentGradeRecord as agr, GradebookAssignment as asn where agr.studentId = :studentid and agr.gradableObject = asn and asn.removed is false and asn.notCounted is false and asn.gradebook.id = :gradebookid and asn.ungraded is false")
.setString("studentid", studentId)
.setLong("gradebookid", gradebookId)
.list();
}
代码示例来源:origin: org.sakaiproject.samigo/samigo-services
public void removeAssessment(final Long assessmentId) {
// if pubAssessment exist, simply set assessment to inactive else delete assessment
List<PublishedAssessmentData> count = (List<PublishedAssessmentData>) getHibernateTemplate()
.findByNamedParam("select count(p) from PublishedAssessmentData p where p.assessmentId = :id", "id", assessmentId);
log.debug("removeAssesment: no. of pub Assessment = {}", count.size());
Iterator iter = count.iterator();
int i = ((Long) iter.next()).intValue();
if (i < 1) {
AssessmentData assessment = (AssessmentData) getHibernateTemplate().load(AssessmentData.class, assessmentId);
AssessmentService s = new AssessmentService();
List resourceIdList = s.getAssessmentResourceIdList(assessment);
if (log.isDebugEnabled()) log.debug("*** we have no. of resource in assessment=" + resourceIdList.size());
s.deleteResources(resourceIdList);
}
final String softDeleteQuery = "update AssessmentData set status = :status WHERE assessmentBaseId = :id";
getHibernateTemplate().execute(session -> {
Query q = session.createQuery(softDeleteQuery);
q.setInteger("status", AssessmentIfc.DEAD_STATUS);
q.setLong("id", assessmentId);
return q.executeUpdate();
});
}
代码示例来源:origin: com.github.albfernandez/jbpm-jpdl
public List calculateAverageTimeByNode(long processDefinitionId, long minumumDurationMillis) {
try {
List tuples = session.getNamedQuery("GraphSession.calculateAverageTimeByNode")
.setLong("processDefinitionId", processDefinitionId)
.setDouble("minimumDuration", minumumDurationMillis)
.list();
if (tuples.isEmpty()) return Collections.EMPTY_LIST;
List results = new ArrayList();
for (Iterator i = tuples.iterator(); i.hasNext();) {
Object[] values = (Object[]) i.next();
AverageNodeTimeEntry entry = new AverageNodeTimeEntry();
entry.setNodeId(((Number) values[0]).longValue());
entry.setNodeName((String) values[1]);
entry.setCount(((Number) values[2]).intValue());
entry.setAverageDuration(((Number) values[3]).longValue());
entry.setMinDuration(((Number) values[4]).longValue());
entry.setMaxDuration(((Number) values[5]).longValue());
results.add(entry);
}
return results;
}
catch (HibernateException e) {
handle(e);
throw new JbpmPersistenceException("could not calculate average time by node "
+ "for process definition " + processDefinitionId, e);
}
}
代码示例来源:origin: gocd/gocd
Modification findLatestModification(final MaterialInstance expandedInstance) {
Modifications modifications = cachedModifications(expandedInstance);
if (modifications != null && !modifications.isEmpty()) {
return modifications.get(0);
}
String cacheKey = latestMaterialModificationsKey(expandedInstance);
synchronized (cacheKey) {
Modification modification = (Modification) getHibernateTemplate().execute((HibernateCallback) session -> {
Query query = session.createQuery("FROM Modification WHERE materialId = ? ORDER BY id DESC");
query.setMaxResults(1);
query.setLong(0, expandedInstance.getId());
return query.uniqueResult();
});
goCache.put(cacheKey, new Modifications(modification));
return modification;
}
}
代码示例来源:origin: sakaiproject/sakai
protected GradebookAssignment getAssignmentWithoutStats(final String gradebookUid, final Long assignmentId) throws HibernateException {
return (GradebookAssignment) getSessionFactory().getCurrentSession()
.createQuery("from GradebookAssignment as asn where asn.id = :assignmentid and asn.gradebook.uid = :gradebookuid and asn.removed is false")
.setLong("assignmentid", assignmentId)
.setString("gradebookuid", gradebookUid)
.uniqueResult();
}
代码示例来源:origin: sakaiproject/sakai
protected List<GradebookAssignment> getAssignments(final Long gradebookId) throws HibernateException {
return getSessionFactory().getCurrentSession()
.createQuery("from GradebookAssignment as asn where asn.gradebook.id = :gradebookid and asn.removed is false")
.setLong("gradebookid", gradebookId)
.list();
}
代码示例来源:origin: sakaiproject/sakai
public long getSubPoolSize(final Long poolId) {
final HibernateCallback<Number> hcb = session -> {
Query q = session.createQuery("select count(qpp) from QuestionPoolData qpp where qpp.parentPoolId = :id");
q.setCacheable(true);
q.setLong("id", poolId);
return (Number) q.uniqueResult();
};
return getHibernateTemplate().execute(hcb).longValue();
}
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
@SuppressWarnings("unchecked")
public List<Long> getTaskInstancesWaitingTimeOfUser(final String username, final ActivityDefinitionUUID taskUUID,
final Date since, final Date until) {
final Query query = getSession().getNamedQuery("getTaskInstancesWaitingTimeOfUserFromActivityDefinitionUUID");
query.setLong("since", since.getTime());
query.setLong("until", until.getTime());
query.setString("activityUUID", taskUUID.getValue());
query.setString("userId", username);
return formatList(query.list());
}
代码示例来源:origin: apache/ctakes
public Double getKernel(KernelEvaluation kernelEvaluation,
long instanceId1, long instanceId2) {
long instanceId1s = instanceId1 <= instanceId2 ? instanceId1
: instanceId2;
long instanceId2s = instanceId1 <= instanceId2 ? instanceId2
: instanceId1;
Query q = this.getSessionFactory().getCurrentSession()
.getNamedQuery("getKernelEvaluation");
q.setCacheable(true);
q.setInteger("kernelEvaluationId",
kernelEvaluation.getKernelEvaluationId());
q.setLong("instanceId1", instanceId1s);
q.setLong("instanceId2", instanceId2s);
KernelEvaluationInstance g = (KernelEvaluationInstance) q
.uniqueResult();
if (g != null) {
return g.getSimilarity();
} else {
return null;
}
}
代码示例来源:origin: sakaiproject/sakai
public QuestionPoolAccessData getQuestionPoolAccessData(final Long poolId,
final String agentId) {
final HibernateCallback<List> hcb = session -> {
Query q = session.createQuery("from QuestionPoolAccessData as qpa where qpa.questionPoolId = :id and qpa.agentId = :agent");
q.setLong("id", poolId);
q.setString("agent", agentId);
return q.list();
};
List list = getHibernateTemplate().execute(hcb);
return (QuestionPoolAccessData) list.get(0);
}
内容来源于网络,如有侵权,请联系作者删除!