本文整理了Java中org.hibernate.Query.setEntity
方法的一些代码示例,展示了Query.setEntity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setEntity
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setEntity
[英]Bind an instance of a mapped persistent class to a JDBC-style query parameter. Use #setParameter(int,Object) for null values.
[中]将映射的持久类的实例绑定到JDBC样式的查询参数。将#setParameter(int,Object)用于空值。
代码示例来源:origin: hibernate/hibernate-orm
/**
* Call setEntity() on a cacheable query - see FORGE-265
*/
public List listEventsOfOrganizer(Person organizer) {
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
Query query = session.createQuery("from Event ev where ev.organizer = :organizer");
query.setCacheable(true);
query.setEntity("organizer", organizer);
List result = query.list();
session.getTransaction().commit();
return result;
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Call setEntity() on a cacheable query - see FORGE-265
*/
public List listEventsOfOrganizer(Person organizer) {
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
Query query = session.createQuery("from Event ev where ev.organizer = :organizer");
query.setCacheable(true);
query.setEntity("organizer", organizer);
List result = query.list();
session.getTransaction().commit();
return result;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.ProgramWorkflowDAO#getProgramsByConcept(org.openmrs.Concept)
*/
@Override
public List<Program> getProgramsByConcept(Concept concept) {
String pq = "select distinct p from Program p where p.concept = :concept";
Query pquery = sessionFactory.getCurrentSession().createQuery(pq);
pquery.setEntity("concept", concept);
return pquery.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.FormDAO#getFormsContainingConcept(org.openmrs.Concept)
*/
@Override
@SuppressWarnings("unchecked")
public List<Form> getFormsContainingConcept(Concept c) throws DAOException {
String q = "select distinct ff.form from FormField ff where ff.field.concept = :concept";
Query query = sessionFactory.getCurrentSession().createQuery(q);
query.setEntity("concept", c);
return query.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.FormDAO#getFormFieldsByField(Field)
*/
@Override
@SuppressWarnings("unchecked")
public List<FormField> getFormFieldsByField(Field field) {
return sessionFactory.getCurrentSession().createQuery("from FormField f where f.field = :field").setEntity("field",
field).list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.ProgramWorkflowDAO#getProgramWorkflowsByConcept(org.openmrs.Concept)
*/
@Override
public List<ProgramWorkflow> getProgramWorkflowsByConcept(Concept concept) {
String wq = "select distinct w from ProgramWorkflow w where w.concept = :concept";
Query wquery = sessionFactory.getCurrentSession().createQuery(wq);
wquery.setEntity("concept", concept);
return wquery.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.ProgramWorkflowDAO#getProgramWorkflowStatesByConcept(org.openmrs.Concept)
*/
@Override
public List<ProgramWorkflowState> getProgramWorkflowStatesByConcept(Concept concept) {
String sq = "select distinct s from ProgramWorkflowState s where s.concept = :concept";
Query squery = sessionFactory.getCurrentSession().createQuery(sq);
squery.setEntity("concept", concept);
return squery.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* returns a list of n-generations of parents of a concept in a concept set
*
* @param Concept current
* @return List<Concept>
* @throws DAOException
*/
@SuppressWarnings("unchecked")
private List<Concept> getParents(Concept current) throws DAOException {
List<Concept> parents = new ArrayList<>();
if (current != null) {
Query query = sessionFactory.getCurrentSession().createQuery(
"from Concept c join c.conceptSets sets where sets.concept = ?").setEntity(0, current);
List<Concept> immedParents = query.list();
for (Concept c : immedParents) {
parents.addAll(getParents(c));
}
parents.add(current);
if (log.isDebugEnabled()) {
log.debug("parents found: ");
for (Concept c : parents) {
log.debug("id: " + c.getConceptId());
}
}
}
return parents;
}
代码示例来源:origin: stackoverflow.com
public List<Program> findBySubscriber(Subscriber subscriber) {
String hql = "select p " +
"from Program p " +
" join p.subscribers s " +
"where s = :sub"
;
Query q = getSession().createQuery(hql);
q.setEntity("sub", subscriber);
List<Program> l = q.list();
return l;
}
代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate
public void setParameterInto(final Query query) {
if (type.equals(Hibernate.OBJECT)) {
query.setEntity(name, value);
} else if (type.equals(DETERMINE)) {
query.setParameter(name, value);
} else {
query.setParameter(name, value, type);
}
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
private void deleteLogs(ProcessInstance processInstance) {
List logs = session.getNamedQuery("GraphSession.findLogsForProcessInstance")
.setEntity("processInstance", processInstance)
.list();
for (Iterator i = logs.iterator(); i.hasNext();) {
session.delete(i.next());
}
}
代码示例来源:origin: OpenNMS/opennms
@Override
public OnmsLocationSpecificStatus doInHibernate(final Session session) throws HibernateException, SQLException {
return (OnmsLocationSpecificStatus)session.createQuery("from OnmsLocationSpecificStatus status where status.locationMonitor = :locationMonitor and status.monitoredService = :monitoredService order by status.pollResult.timestamp desc")
.setEntity("locationMonitor", locationMonitor)
.setEntity("monitoredService", monSvc)
.setMaxResults(1)
.uniqueResult();
}
代码示例来源:origin: com.github.albfernandez/jbpm-jpdl
private List findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
return session.getNamedQuery("GraphSession.findReferencingProcessStates")
.setEntity("subProcessDefinition", subProcessDefinition)
.list();
}
代码示例来源:origin: com.github.albfernandez/jbpm-jpdl
private void deleteSubProcesses(ProcessInstance processInstance) {
List subProcessInstances = session.getNamedQuery("GraphSession.findSubProcessInstances")
.setEntity("processInstance", processInstance)
.list();
for (Iterator i = subProcessInstances.iterator(); i.hasNext();) {
ProcessInstance subProcessInstance = (ProcessInstance) i.next();
deleteProcessInstance(subProcessInstance);
}
}
代码示例来源:origin: org.motechproject/motech-server-core
public Facility facilityFor(Patient patient) {
return (Facility) sessionFactory.getCurrentSession().createQuery(
"from " + Facility.class.getName()
+ " f where :patient in elements(f.patients)")
.setEntity("patient", patient).uniqueResult();
}
代码示例来源:origin: org.nakedobjects.examples/expenses-hibernate
@Override
@Hidden
public List<ExpenseItem> findExpenseItemsOfType(final Employee employee, final ExpenseType type) {
// example query implementation
final Query query = hibernateHelper.createEntityQuery("o.expenseType = ? and o.claim.claimant = ?",
AbstractExpenseItem.class);
query.setEntity(0, type);
query.setEntity(1, employee);
return hibernateHelper.findByQuery(query, ExpenseItem.class);
}
}
代码示例来源:origin: com.github.albfernandez/jbpm-jpdl
private void deleteJobs(ProcessInstance processInstance) {
session.getNamedQuery("GraphSession.deleteJobsForProcessInstance")
.setEntity("processInstance", processInstance)
.executeUpdate();
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
public List findActiveNodesByProcessInstance(ProcessInstance processInstance) {
try {
return session.getNamedQuery("GraphSession.findActiveNodesByProcessInstance")
.setEntity("processInstance", processInstance)
.list();
}
catch (HibernateException e) {
handle(e);
throw new JbpmPersistenceException("could not find active nodes for "
+ processInstance, e);
}
}
代码示例来源:origin: org.jbpm/pvm
public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
// query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.job.hbm.xml
Query query = session.getNamedQuery("findExclusiveJobs");
query.setTimestamp("now", Clock.getCurrentTime());
query.setEntity("processInstance", processInstance);
return query.list();
}
代码示例来源:origin: sakaiproject/sakai
private GradebookAssignment getExternalAssignment(final String gradebookUid, final String externalId)
throws GradebookNotFoundException {
final Gradebook gradebook = getGradebook(gradebookUid);
final HibernateCallback<GradebookAssignment> hc = session -> (GradebookAssignment) session
.createQuery("from GradebookAssignment as asn where asn.gradebook = :gradebook and asn.externalId = :externalid")
.setEntity("gradebook", gradebook)
.setString("externalid", externalId)
.uniqueResult();
return getHibernateTemplate().execute(hc);
}
内容来源于网络,如有侵权,请联系作者删除!