db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql SqlQueryStatement.java
Date Wed, 26 Mar 2003 20:57:37 GMT
brj         2003/03/26 12:57:37

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  prefix * with alias (A0.*)
  
  Revision  Changes    Path
  1.30      +39 -23    db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- SqlQueryStatement.java	21 Mar 2003 19:50:59 -0000	1.29
  +++ SqlQueryStatement.java	26 Mar 2003 20:57:36 -0000	1.30
  @@ -196,36 +196,49 @@
      
       /**
        * Answer the column name for alias and path info<br>
  -     * if a FieldDescriptor is found for the Criteria the colName is taken from
  -     * there otherwise its taken from Criteria. <br>
  -     * if translate try to convert attribute name into column name
  +     * if translate try to convert attribute name into column name otherwise use attribute
name<br>
  +     * if a FieldDescriptor is found for the attribute name the column name is taken from
  +     * there prefixed with the alias (firstname -> A0.F_NAME). 
  +     * '*' is also returned as 'alias.*' .  
        * 
        * @param aTableAlias
        * @param aPathInfo
        * @param translate
        * @return
        */  
  -    protected String getColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate)
  -    {
  -        FieldDescriptor fld = null;
  -        String result;
  +	protected String getColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate)
  +	{
  +		FieldDescriptor fld = null;
  +		String result = null;
   
  -        if (translate)
  -        {     
  -            fld = getFieldDescriptor(aTableAlias, aPathInfo);
  -        }
  - 
  -        if (fld != null)
  -        {
  -            result = aTableAlias.alias + "." + fld.getColumnName();
  -        }
  +
  +		if (translate)
  +		{
  +            // translate attribute name into column name
  +			fld = getFieldDescriptor(aTableAlias, aPathInfo);
  +
  +			if (fld != null)
  +			{
  +				result = aTableAlias.alias + "." + fld.getColumnName();
  +			}
  +            else if ("*".equals(aPathInfo.column))
  +            {
  +                result = aTableAlias.alias + "." + aPathInfo.column;
  +            }
  +            else
  +            {
  +                // throw new IllegalArgumentException("Now Field found for : " + aPathInfo.column);
  +                result = aPathInfo.column;
  +            }
  +		}
           else
           {
  +            // use attribute name
               result = aPathInfo.column;
           }
  -       
  -       return result;
  -    }
  +
  +		return result;
  +	}
       
       /**
        * Add the Column to the StringBuffer <br>
  @@ -234,8 +247,9 @@
        * @param aPathInfo
        * @param translate
        * @param buf
  +     * @return true if appended
        */
  -	protected void appendColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate,
StringBuffer buf)
  +	protected boolean appendColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate,
StringBuffer buf)
   	{
   		String functionName = aPathInfo.function;
   		String colName = getColName(aTableAlias, aPathInfo ,translate);
  @@ -251,6 +265,8 @@
           {
               buf.append(")");
           }
  +        
  +        return true;
       }
   
       /**
  @@ -311,12 +327,12 @@
        * ie: name from FIELDDESCRIPTOR , UPPER(name_test) from Criteria<br>
        * also resolve pathExpression adress.city or owner.konti.saldo
        */
  -    protected void appendColName(String attr, boolean useOuterJoins, String aUserAlias,
StringBuffer buf)
  +    protected boolean appendColName(String attr, boolean useOuterJoins, String aUserAlias,
StringBuffer buf)
       {
           AttributeInfo attrInfo = getAttributeInfo(attr, useOuterJoins, aUserAlias);
           TableAlias tableAlias = attrInfo.tableAlias;
               
  -        appendColName(tableAlias, attrInfo.pathInfo, true, buf);
  +        return appendColName(tableAlias, attrInfo.pathInfo, true, buf);
       }
   
     
  
  
  

Mime
View raw message