本文整理了Java中org.hibernate.Query.setParameters
方法的一些代码示例,展示了Query.setParameters
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setParameters
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setParameters
[英]Bind values and types to positional parameters. Allows binding more than one at a time; no real performance impact. The number of elements in each array should match. That is, element number-0 in types array corresponds to element-0 in the values array, etc,
[中]
代码示例来源:origin: stackoverflow.com
sessionFactory = getHibernateTemplate().getSessionFactory();
Session session = sessionFactory.getCurrentSession();
Query query = session
.createQuery("select value from table where ...");
query.setParameters("param1", value1);
result = (Type) query.uniqueResult();
代码示例来源:origin: riotfamily/riot
public TypedQuery<T> setParameters(Object[] values, Type[] types) throws HibernateException {
query.setParameters(values, types);
return this;
}
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public Query setParameters(Object[] objects, Type[] types) {
return query.setParameters(objects, types);
}
代码示例来源:origin: ezbz/projectx
@Override
public Query setParameters(final Object[] values, final Type[] types) throws HibernateException {
return query.setParameters(values, types);
}
代码示例来源:origin: org.sakaiproject/sakai-rwiki-impl
public Object doInHibernate(Session session)
throws HibernateException
{
String search = basepath.replaceAll("([A%_])", "A$1"); //$NON-NLS-1$ //$NON-NLS-2$
return session
.createQuery(
"from RWikiCurrentObjectImpl as r " //$NON-NLS-1$
+ "where r.name like concat(?,'%') escape 'A' " //$NON-NLS-1$
+ "and r.version >= ? " //$NON-NLS-1$
+ "order by r.version desc, r.name asc") //$NON-NLS-1$
.setParameters(new Object[] { search, time },
new Type[] { Hibernate.STRING, Hibernate.DATE })
.list();
}
};
代码示例来源:origin: stackoverflow.com
//sessionFactory = getHibernateTemplate().getSessionFactory();
Session session = getSessionFactory().getCurrentSession();
Query query = session.createQuery("select value from table where ...");
query.setParameters("param1", value1);
result = (Type) query.uniqueResult(); //The type is you desired result type.
//test for null here if needed
代码示例来源:origin: org.sakaiproject/sakai-rwiki-impl
public Object doInHibernate(Session session)
throws HibernateException
{
return session
.createQuery(
"select distinct r " //$NON-NLS-1$
+ " from RWikiCurrentObjectImpl as r, " //$NON-NLS-1$
+ " RWikiCurrentObjectContentImpl as c " //$NON-NLS-1$
+ " where r.realm = ? and (" //$NON-NLS-1$
+ " lower(r.name) like ? or " //$NON-NLS-1$
+ " lower(c.content) like ? " //$NON-NLS-1$
+ expression.toString() + " ) and " //$NON-NLS-1$
+ " r.id = c.rwikiid " //$NON-NLS-1$
+ " order by r.name ").setParameters( //$NON-NLS-1$
criteriaList.toArray(), types).list();
}
};
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery("select value from table where param1 = :param1").addScalar("value", StandardBasicTypes.STRING);
query.setParameters("param1", value1);
result = (String) query.uniqueResult();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery("select value from table where param1 = :param1").addScalar("value", Type);
query.setParameters("param1", value1);
result = (Type) query.uniqueResult();
代码示例来源:origin: net.sf.jabb/jabb-core
/**
* Setup a query with parameters and other configurations.
* @param query
* @param paramValues
* @param paramTypes
* @param offset
* @param limit
*/
private void setupQuery(Query query, Object[] paramValues, Type[] paramTypes, Integer offset, Integer limit){
if (paramValues != null && paramTypes != null){
query.setParameters(paramValues, paramTypes);
}
if (offset != null){
query.setFirstResult(offset);
}
if (limit != null){
query.setMaxResults(limit);
}
}
内容来源于网络,如有侵权,请联系作者删除!