From ae7064145dcab206b758967a484c145a10f134b9 Mon Sep 17 00:00:00 2001 From: trifonnt Date: Sun, 2 Nov 2008 19:20:07 +0000 Subject: [PATCH] One class per day initiative. FR: [ 2214883 ] Remove SQL code and Replace for Query https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2214883&group_id=176962 --- .../src/org/compiere/model/MAcctSchemaGL.java | 50 ++++++------------- base/src/org/compiere/model/MAchievement.java | 2 +- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/base/src/org/compiere/model/MAcctSchemaGL.java b/base/src/org/compiere/model/MAcctSchemaGL.java index 2643ecc4e2..a728c649e4 100644 --- a/base/src/org/compiere/model/MAcctSchemaGL.java +++ b/base/src/org/compiere/model/MAcctSchemaGL.java @@ -16,11 +16,12 @@ *****************************************************************************/ package org.compiere.model; -import java.sql.*; -import java.util.*; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Properties; -import java.util.logging.*; -import org.compiere.util.*; +import org.compiere.util.CLogger; +import org.compiere.util.KeyNamePair; /** * Accounting Schema GL info @@ -30,6 +31,12 @@ import org.compiere.util.*; */ public class MAcctSchemaGL extends X_C_AcctSchema_GL { + /** + * + */ + private static final long serialVersionUID = 1L; + + /** * Get Accounting Schema GL Info * @param ctx context @@ -38,36 +45,11 @@ public class MAcctSchemaGL extends X_C_AcctSchema_GL */ public static MAcctSchemaGL get (Properties ctx, int C_AcctSchema_ID) { - MAcctSchemaGL retValue = null; - String sql = "SELECT * FROM C_AcctSchema_GL WHERE C_AcctSchema_ID=?"; - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, C_AcctSchema_ID); - ResultSet rs = pstmt.executeQuery(); - if (rs.next()) - { - retValue = new MAcctSchemaGL (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; - } + String whereClause = "C_AcctSchema_ID=?"; + MAcctSchemaGL retValue = new Query(ctx, MAcctSchemaGL.Table_Name, whereClause, null) + .setParameters(new Object[]{C_AcctSchema_ID}) + .first() + ; return retValue; } // get diff --git a/base/src/org/compiere/model/MAchievement.java b/base/src/org/compiere/model/MAchievement.java index 41d7906901..41fe1a2c52 100644 --- a/base/src/org/compiere/model/MAchievement.java +++ b/base/src/org/compiere/model/MAchievement.java @@ -54,7 +54,7 @@ public class MAchievement extends X_PA_Achievement .setParameters(new Object[]{PA_Measure_ID}).setOrderBy("SeqNo, DateDoc").list(); MAchievement[] retValue = new MAchievement[list.size ()]; - list.toArray (retValue); + retValue = list.toArray (retValue); return retValue; } // getOfMeasure