Hibernate~DAO
@SuppressWarnings("unchecked") public ElectroplateVO findByOrganizationIdAndWipEntityId(final String wipEntityId) ElectroplateVO data =(ElectroplateVO)this.getHibernateTemplate().execute(new HibernateCallback<Object>() { @Override public Object doInHibernate(Session session) throws HibernateException, SQLException { StringBuilder sql = new StringBuilder(); sql语句 Query query =session.createSQLQuery(sql.toString()).setCacheable(false);// 不启用查询缓存结果 if(null != wipEntityId) {
query.setString("wipEntityId", wipEntityId);
} List<Object[]> list = query.list(); ElectroplateVO electroplateVO = new ElectroplateVO(); for(Object[] row : list){ electroplateVO.setInventoryItemNumber(null == row[0 ] ? null : (String)row[0]); electroplateVO.setDepartmentCode(null == row[1 ] ? null : (String)row[1]); } return electroplateVO; } }); return data; }