DreamTiger的梦幻乐园

随便写写,自得其乐,生活就是这样

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  29 Posts :: 0 Stories :: 13 Comments :: 0 Trackbacks
代码一:
    DetachedCriteria dc = DetachedCriteria.forClass(classT, "p");
    dc.add(Restrictions.eq(
"purePeptide", purePeptide));
    dc.add(Restrictions.eq(
"project.id", projectId));
    dc.addOrder(Order.asc(
"peptide"));

代码二:
    DetachedCriteria dc = DetachedCriteria.forClass(classT, "p");
    dc.add(Restrictions.eq(
"p.purePeptide", purePeptide));
    dc.add(Restrictions.eq(
"project.id", projectId));
    dc.addOrder(Order.asc(
"peptide"));

两段代码唯一的区别就是第二句是使用"purePeptide"还是"p.purePeptide"。
代码一产生的sql语句:
select this_.purePeptide as y1_, this_.peptide as y2_ from SequestPeptide this_ where y1_ = 'NASILLEELDLEK' and this_.project_id=1 order by y2_ asc
运行会报Unknown column name:Y1_

代码二产生的正确的sql语句:
select this_.purePeptide as y1_, this_.peptide as y2_ from SequestPeptide this_ where this_.purePeptide='NASILLEELDLEK' and this_.project_id=1 order by y2_ asc
posted on 2006-02-23 21:13 梦幻乐园 阅读(1431) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: