minor fixes - now ad_client_id+value is a unique index

This commit is contained in:
Carlos Ruiz 2008-11-17 15:47:17 +00:00
parent ee0e0e6f17
commit 8b7c179551
1 changed files with 8 additions and 7 deletions

View File

@ -30,9 +30,11 @@
package org.compiere.model; package org.compiere.model;
import java.util.*; import java.sql.ResultSet;
import org.compiere.util.*; import java.util.List;
import java.sql.*; import java.util.Properties;
import org.compiere.util.Env;
/** /**
* *
* @author Daniel Tamm * @author Daniel Tamm
@ -66,16 +68,15 @@ public class MFreightCategory extends X_M_FreightCategory {
* Reads a freight category from database based on the value (key) of the category. * Reads a freight category from database based on the value (key) of the category.
* No cache is used. * No cache is used.
* *
* @param ctx Context. The context is used to match only categories within the * @param ctx Context. The context is used to match only categories within the client.
* client and organization context.
* @param value * @param value
* @param trxName * @param trxName
* @return If a match is found, the freight category. No match returns null. * @return If a match is found, the freight category. No match returns null.
*/ */
public static MFreightCategory getByValue(Properties ctx, String value, String trxName) { public static MFreightCategory getByValue(Properties ctx, String value, String trxName) {
Query q = new Query(ctx, MFreightCategory.Table_Name, "value=? and ad_client_id=? and (ad_org_id=? or ad_org_id=0)", trxName); Query q = new Query(ctx, MFreightCategory.Table_Name, "Value=? AND AD_Client_ID=?", trxName);
q.setParameters(new Object[]{value, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx)}); q.setParameters(new Object[]{value, Env.getAD_Client_ID(ctx)});
List<MFreightCategory> list = q.list(); List<MFreightCategory> list = q.list();
if (list.size()>0) { if (list.size()>0) {
return(list.get(0)); return(list.get(0));