From 8d6cd95f504942f56a37c5949de53c164f4b63d4 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Fri, 5 Mar 2010 14:34:10 +0000 Subject: [PATCH] FR: [ 2214883 ] Remove SQL code and Replace for Query -- JUnit test pending Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- base/src/org/compiere/model/MAttachment.java | 33 +++----------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/base/src/org/compiere/model/MAttachment.java b/base/src/org/compiere/model/MAttachment.java index a6d0191c6b..46bc4ac755 100644 --- a/base/src/org/compiere/model/MAttachment.java +++ b/base/src/org/compiere/model/MAttachment.java @@ -80,35 +80,10 @@ public class MAttachment extends X_AD_Attachment */ public static MAttachment get (Properties ctx, int AD_Table_ID, int Record_ID) { - MAttachment retValue = null; - PreparedStatement pstmt = null; - String sql = "SELECT * FROM AD_Attachment WHERE AD_Table_ID=? AND Record_ID=?"; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, AD_Table_ID); - pstmt.setInt (2, Record_ID); - ResultSet rs = pstmt.executeQuery (); - if (rs.next ()) - retValue = new MAttachment (ctx, rs, null); - rs.close (); - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - s_log.log(Level.SEVERE, sql, e); - } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } + final String whereClause = I_AD_Attachment.COLUMNNAME_AD_Table_ID+"=? AND "+I_AD_Attachment.COLUMNNAME_Record_ID+"=?"; + MAttachment retValue = new Query(ctx,I_AD_Attachment.Table_Name,whereClause, null) + .setParameters(AD_Table_ID, Record_ID) + .first(); return retValue; } // get