我想按name查询在hibernate中用HQL怎么实现??要是用findByProperty这儿方法怎么实现??、
解决方案 »
- sql语句注入
- Hibernate怎样用update加in语句,高手请进,急急!!
- 渲染数据是什么意思??。。。
- tomcat启动报错
- struts的form表单中类型为integer的值,若为+6的形式,在action里得到该表单的值变成0了
- ibaties 遇到的问题 求教
- hibernate同时处理很多数据会不会出现问题
- 请大家看一下这个程序错在哪里?好象没什么错误但却出现了52个错误!
- 急急!~~!如何使weblogic不需要重新启动
- 求助!关于WEB项目servlet启动出了问题。
- 急!关于jdbc并发问题: 有二个客户端先后更新oracle库上的某一条数据。因为一些原因造成第一次更新持续等
- 【求助】系统验证邮件发送问题?
<property name="userName" type="java.lang.String">
<column name="USER_NAME" length="20"/>
</property> dao:
public List findByProperty(String propertyName, Object value) {
log.debug("finding User instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from User as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
调用:List list = findByProperty("userName", "姓名") ;
log.debug("finding Zone instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Zone as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
Serviceimpl中我不知道怎么给参数
public List<Zone> findByProperty(String propertyName, Object value)
throws Exception {
// TODO Auto-generated method stub
return zoneDAO.findByProperty(propertyName, propertyName);
}还有在action中我不知道怎么给参数
user 指的是什么啊?还有姓名?
(String propertyName, Object value)
propertyName 传你的Zone类中对应的你要查的字段的名称,value 传你要查的条件的值