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"q是"p.purePeptide"?br>代码一产生的sql语句Q?br>select this_.purePeptide as y1_, this_.peptide as y2_ from SequestPeptide this_ where y1_ = 'NASILLEELDLEK' and this_.project_id=1 order by y2_ asc
q行会报Unknown column name:Y1_
代码二生的正确的sql语句Q?br>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

]]>