Naked Search in service
public List<TplRelease> searchTplReleaseById(TplRelease tr)throws Exception{ DBOperator dbo = getDBOperator(); try{ List<TplRelease> tplReleaseList = new ArrayList<TplRelease>(); String sqlWhere = "select b.* from "+ "(SELECT max(a.CREATE_TIME) AS CREATE_TIME , a.TPL_ID FROM template.tpl_release a WHERE a.TPL_ID =? AND a.TPL_STATUS ='1' GROUP BY a.TPL_ID ) c "+ " left join template.tpl_release b on c.CREATE_TIME = b.CREATE_TIME and c.TPL_ID = b.TPL_ID"; PreparedStatement pst = dbo.createPreparedStatement(sqlWhere); pst.setString(1,tr.getTplID()); ResultSet rs = pst.executeQuery(); while (rs.next()) { TplRelease tplRelease = new TplRelease(); tplRelease.setTplID(rs.getString("Tpl_ID")); tplRelease.setTplVersion(rs.getString("Tpl_Version")); tplRelease.setTplName(rs.getString("Tpl_Name")); tplRelease.setTplNamePy(rs.getString("Tpl_Name_Py")); tplRelease.setTplDesc(rs.getString("Tpl_Desc")); tplRelease.setTplData(rs.getString("Tpl_Data")); tplRelease.setTplStatus(rs.getString("Tpl_Status")); tplRelease.setTreeNode(rs.getString("Tree_Node")); tplRelease.setNodeIndex(rs.getString("Node_Index")); tplRelease.setCreator(rs.getString("Creator")); tplRelease.setCreateTime(rs.getString("Create_Time")); tplRelease.setModifier(rs.getString("Modifier")); tplRelease.setModifyTime(rs.getString("Modify_Time")); tplRelease.setOwnerOrg(rs.getString("Owner_Org")); tplRelease.setInoutFlag(rs.getString("Inout_Flag")); tplRelease.setTplType(rs.getString("Tpl_Type")); tplReleaseList.add(tplRelease); } dbo.commit(); return tplReleaseList; }catch(Exception e){ dbo.rollback(); throw e; }finally{ dbo.close(); } }