IDEMPIERE-4723 - refactor MArchive.get to use the Query class instead… (#1314)
* IDEMPIERE-4723 - refactor MArchive.get to use the Query class instead of PreparedStatement, following best practices * IDEMPIERE-4723 - refactor MArchive.get to use the Query class instead of PreparedStatement, following best practices
This commit is contained in:
parent
35cda7ffe8
commit
7d5f7f678c
|
@ -25,6 +25,7 @@ import java.nio.file.Path;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ import org.compiere.tools.FileUtil;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Archive Model
|
* Archive Model
|
||||||
|
@ -59,28 +61,15 @@ public class MArchive extends X_AD_Archive {
|
||||||
* @return archives
|
* @return archives
|
||||||
*/
|
*/
|
||||||
public static MArchive[] get(Properties ctx, String whereClause) {
|
public static MArchive[] get(Properties ctx, String whereClause) {
|
||||||
ArrayList<MArchive> list = new ArrayList<MArchive>();
|
StringBuilder sql = new StringBuilder("AD_Client_ID=?");
|
||||||
StringBuilder sql = new StringBuilder("SELECT * FROM AD_Archive WHERE AD_Client_ID=?");
|
if (!Util.isEmpty(whereClause))
|
||||||
if (whereClause != null && whereClause.length() > 0)
|
|
||||||
sql.append(whereClause);
|
sql.append(whereClause);
|
||||||
sql.append(" ORDER BY Created");
|
|
||||||
PreparedStatement pstmt = null;
|
List<MArchive> list = new Query(ctx, Table_Name, sql.toString(),null)
|
||||||
ResultSet rs = null;
|
.setParameters(Env.getAD_Client_ID(ctx))
|
||||||
try {
|
.setOrderBy(COLUMNNAME_Created)
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
.list();
|
||||||
pstmt.setInt(1, Env.getAD_Client_ID(ctx));
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
list.add(new MArchive(ctx, rs, null));
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
rs = null;
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
if (list.size() == 0)
|
if (list.size() == 0)
|
||||||
s_log.fine(sql.toString());
|
s_log.fine(sql.toString());
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue