日期:2014-05-18  浏览次数:20646 次

很简单的问题,为什么我的hibernate返回空值?
我的dao中是这样写的:
public   List   findByProperty(String   propertyName,   Object   value)   {
log.debug( "finding   ReptAgilityConfig   instance   with   property:   "
+   propertyName   +   ",   value:   "   +   value);
try   {
String   queryString   =   "from   ReptAgilityConfig   as   model ";
return   getHibernateTemplate().find(queryString);
}   catch   (RuntimeException   re)   {
log.error( "find   by   property   name   failed ",   re);
throw   re;
}
}
返回的list是空的。
还有啊,我用myeclipse自动把数据库中的表映射成hibernate所需要的类,生成了2个,一个ReptAgilityConfig,里面只有一个id;另一个是ReptAgilityConfigId,里面对应了数据库表中的一些字段。在上面的dao中,propertyName填成表中的任意字段都会出错(因为它只有一个成员id),那么我该怎么用它呢?
高手来帮我啊,我只有这么多分了。

------解决方案--------------------
帮你顶顶吧 我也不清楚............
------解决方案--------------------
把from ReptAgilityConfig as model写成from ReptAgilityConfig,试试看
------解决方案--------------------
最好是把表、MAP文件、类放上来看看
------解决方案--------------------
public List findByProperty(String propertyName, Object value)
你不用这个方法 自己写个方法啊
public List findByYzdh() {
log.debug( "finding GsTjjlTzjlcxView instance with property " );
try {
String queryString = "from ReptAgilityConfig ;
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error( "find by property name failed ", re);
throw re;
}
}
在ReptAgilityConfig 前面写上它的路径