db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: svn commit: r372989 - in /db/ojb/branches/OJB_1_0_RELEASE/src: java/org/apache/ojb/broker/accesslayer/sql/ java/org/apache/ojb/broker/platforms/ schema/ test/org/apache/ojb/broker/
Date Sat, 28 Jan 2006 09:06:58 GMT
hi armin,

you're right. it's done now.

jakob

Armin Waibel schrieb:
> Hi Jakob,
> 
> could it be that you forget to check in metadata mapping for 
> org.apache.ojb.broker.QuotedTest$QuotedArticle?
> 
> regards,
> Armin
> 
> brj@apache.org wrote:
>> Author: brj
>> Date: Fri Jan 27 13:23:30 2006
>> New Revision: 372989
>>
>> URL: http://svn.apache.org/viewcvs?rev=372989&view=rev
>> Log:
>> bugfix and testcase for quoted names
>>
>> Added:
>>     
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QuotedTest.java 
>>
>> Modified:
>>     
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java

>>
>>     
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java

>>
>>     db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml
>>     
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java 
>>
>>
>> Modified: 
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java

>>
>> URL: 
>> http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java?rev=372989&r1=372988&r2=372989&view=diff

>>
>> ============================================================================== 
>>
>> --- 
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java

>> (original)
>> +++ 
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java

>> Fri Jan 27 13:23:30 2006
>> @@ -1584,6 +1584,17 @@
>>      }
>>  
>>      /**
>> +     * Append the TableAlias
>> +     * @param anAlias
>> +     * @param buf
>> +     */
>> +    private void appendTableAlias(TableAlias anAlias, StringBuffer buf)
>> +    {
>> +        appendTable(anAlias.table, buf);
>> +        buf.append(" ").append(anAlias.alias);
>> +    }
>> +
>> +    /**
>>       * Appends to the statement table and all tables joined to it.
>>       * @param alias the table alias
>>       * @param where append conditions for WHERE clause here
>> @@ -1604,14 +1615,14 @@
>>              if (getQuery() instanceof MtoNQuery)
>>              {
>>                  MtoNQuery mnQuery = (MtoNQuery)m_query; 
>> -                
>> buf.append(getTableAliasForPath(mnQuery.getIndirectionTable(), 
>> null).getTableAndAlias());
>> +                
>> appendTableAlias(getTableAliasForPath(mnQuery.getIndirectionTable(), 
>> null), buf);
>>                  buf.append(", ");
>>              }           -            
>> buf.append(alias.getTableAndAlias());
>> +            appendTableAlias(alias, buf);
>>          }
>>          else if (joinSyntax != SQL92_NOPAREN_JOIN_SYNTAX)
>>          {
>> -            buf.append(alias.getTableAndAlias());
>> +            appendTableAlias(alias, buf);
>>          }
>>  
>>          if (!alias.hasJoins())
>>
>> Modified: 
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java

>>
>> URL: 
>> http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java?rev=372989&r1=372988&r2=372989&view=diff

>>
>> ============================================================================== 
>>
>> --- 
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java

>> (original)
>> +++ 
>> db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java

>> Fri Jan 27 13:23:30 2006
>> @@ -455,7 +455,14 @@
>>       */
>>      public String quoteName(String aString)
>>      {
>> -        return SqlHelper.stripOjbQuotes(aString);
>> +        String result = SqlHelper.stripOjbQuotes(aString);
>> +        +        if (aString.length() > result.length())
>> +        {
>> +            result = getQuotedName(result);           +        }
>> +               +        return result;      }
>>           /**
>>
>> Modified: db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml
>> URL: 
>> http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml?rev=372989&r1=372988&r2=372989&view=diff

>>
>> ============================================================================== 
>>
>> --- db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml 
>> (original)
>> +++ db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml Fri 
>> Jan 27 13:23:30 2006
>> @@ -74,6 +74,18 @@
>>      </foreign-key>
>>    </table>
>>  
>> +    <table name="QUOTED_ARTICLE">
>> +        <column name="ARTICLE_ID" required="true" primaryKey="true" 
>> type="INTEGER"/>
>> +        <column name="ARTICLE_NAME" type="VARCHAR" size="150"/>
>> +        <column name="GROUP_ID" type="INTEGER"/>
>> +        <column name="UNIT" type="VARCHAR" size="150"/>
>> +        <column name="PRICE" type="FLOAT"/>
>> +        <column name="STOCK" type="INTEGER"/>
>> +        <foreign-key foreignTable="Kategorien">
>> +          <reference local="GROUP_ID" foreign="Kategorie_Nr"/>
>> +        </foreign-key>
>> +    </table>
>> +
>>    <table name="BOOKS">
>>      <column name="Artikel_Nr" required="true" primaryKey="true" 
>> type="INTEGER"/>
>>      <column name="Artikelname" type="VARCHAR" size="150"/>
>>
>> Modified: 
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java 
>>
>> URL: 
>> http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java?rev=372989&r1=372988&r2=372989&view=diff

>>
>> ============================================================================== 
>>
>> --- 
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java 
>> (original)
>> +++ 
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java 
>> Fri Jan 27 13:23:30 2006
>> @@ -48,6 +48,7 @@
>>          suite.addTestSuite(QueryTest.class);
>>          suite.addTestSuite(EmptyTableTest.class);
>>          suite.addTestSuite(PersistenceBrokerTest.class);
>> +        suite.addTestSuite(QuotedTest.class);                 
>> suite.addTestSuite(BrokerExamples.class);
>>          suite.addTestSuite(ProxyExamples.class);
>>          suite.addTestSuite(PolymorphicExtents.class);
>>
>> Added: 
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QuotedTest.java 
>>
>> URL: 
>> http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QuotedTest.java?rev=372989&view=auto

>>
>> ============================================================================== 
>>
>> --- 
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QuotedTest.java 
>> (added)
>> +++ 
>> db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QuotedTest.java 
>> Fri Jan 27 13:23:30 2006
>> @@ -0,0 +1,253 @@
>> +/*
>> + * Created on 25.11.2004
>> + *
>> + * To change the template for this generated file go to
>> + * Window>Preferences>Java>Code Generation>Code and Comments
>> + */
>> +package org.apache.ojb.broker;
>> +
>> +import java.util.Collection;
>> +
>> +import org.apache.ojb.broker.query.Criteria;
>> +import org.apache.ojb.broker.query.Query;
>> +import org.apache.ojb.broker.query.QueryFactory;
>> +import org.apache.ojb.junit.PBTestCase;
>> +
>> +/**
>> + * Test for Quoted Identifiers.
>> + *
>> + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
>> + * @version $Id: QuotedTest.java 364933 2005-08-27 12:44:04Z arminw $
>> + */
>> +public class QuotedTest extends PBTestCase
>> +{
>> +    private static final String ARTICLE_NAME = "Quoted Article";
>> +    private static final String PG_NAME = "Quoted Article ProductGroup";
>> +    +    public static void main(String[] args)
>> +    {
>> +        String[] arr = {QuotedTest.class.getName()};
>> +        junit.textui.TestRunner.main(arr);
>> +    }
>> +
>> +    public void testRead()
>> +    {
>> +        String name = "_testRead_" + System.currentTimeMillis();
>> +        Integer lastInsert= null;
>> +        broker.beginTransaction();
>> +        for(int i=0;i<10;i++)
>> +        {
>> +            QuotedArticle a = new QuotedArticle();
>> +            a.setArticleName(ARTICLE_NAME + name);
>> +            a.setUnit("123");
>> +            broker.store(a);
>> +            if(i==9)
>> +            {
>> +                lastInsert = a.getArticleId();
>> +            }
>> +        }
>> +        broker.commitTransaction();
>> +
>> +        Criteria crit = new Criteria();
>> +        Criteria critSub = new Criteria();
>> +        critSub.addLike("articleName", ARTICLE_NAME + name);
>> +        crit.addAndCriteria(critSub);
>> +        crit.addLessThan("articleId", lastInsert);
>> +        Query q = QueryFactory.newQuery(QuotedArticle.class, crit);
>> +
>> +        Collection results = broker.getCollectionByQuery(q);
>> +        assertNotNull(results);
>> +        assertEquals(9, results.size());
>> +
>> +        // compare with count
>> +        int count = broker.getCount(q);
>> +        assertEquals(results.size(), count);       +    }
>> +    +    public void testInsert()
>> +    {
>> +        String postfix = "_" + System.currentTimeMillis();
>> +        QuotedArticle a = new QuotedArticle();
>> +        ProductGroup pg = new ProductGroup();
>> +
>> +        pg.setGroupName(PG_NAME + postfix);
>> +        a.setArticleName(ARTICLE_NAME + postfix);
>> +        a.setUnit("123");
>> +        a.setProductGroup(pg);
>> +
>> +        broker.beginTransaction();
>> +        broker.store(a);
>> +        broker.commitTransaction();
>> +        +        broker.clearCache();
>> +        +        Criteria crit = new Criteria();
>> +        crit.addEqualTo("articleName", ARTICLE_NAME + postfix);
>> +        Query q = QueryFactory.newQuery(QuotedArticle.class, crit);
>> +
>> +        Collection results = broker.getCollectionByQuery(q);
>> +        assertNotNull(results);
>> +        assertEquals(1, results.size());
>> +    }
>> +
>> +    public void testUpdate()
>> +    {
>> +        String postfix = "_" + System.currentTimeMillis();
>> +        QuotedArticle a = new QuotedArticle();
>> +        ProductGroup pg = new ProductGroup();
>> +
>> +        pg.setGroupName(PG_NAME + postfix);
>> +        a.setArticleName(ARTICLE_NAME + postfix);
>> +        a.setUnit("123");
>> +        a.setProductGroup(pg);
>> +
>> +        broker.beginTransaction();
>> +        broker.store(a);
>> +        broker.commitTransaction();
>> +        Identity id = broker.serviceIdentity().buildIdentity(a);
>> +        +        broker.clearCache();
>> +        +        QuotedArticle result = (QuotedArticle) 
>> broker.getObjectByIdentity(id);
>> +        assertNotNull(result);
>> +        assertEquals(result.getArticleName(), ARTICLE_NAME + postfix);
>> +        +        result.setArticleName(ARTICLE_NAME + "_Updated" + 
>> postfix);
>> +        broker.beginTransaction();
>> +        broker.store(result);
>> +        broker.commitTransaction();
>> +
>> +        broker.clearCache();
>> +        +        QuotedArticle updatedResult = (QuotedArticle) 
>> broker.getObjectByIdentity(id);
>> +        assertNotNull(updatedResult);
>> +        assertEquals(updatedResult.getArticleName(), ARTICLE_NAME + 
>> "_Updated" + postfix);
>> +    }
>> +
>> +    public void testDelete()
>> +    {
>> +        String postfix = "_" + System.currentTimeMillis();
>> +        QuotedArticle a = new QuotedArticle();
>> +        ProductGroup pg = new ProductGroup();
>> +
>> +        pg.setGroupName(PG_NAME + postfix);
>> +        a.setArticleName(ARTICLE_NAME + postfix);
>> +        a.setUnit("123");
>> +        a.setProductGroup(pg);
>> +
>> +        broker.beginTransaction();
>> +        broker.store(a);
>> +        broker.commitTransaction();
>> +        Identity id = broker.serviceIdentity().buildIdentity(a);
>> +        +        broker.clearCache();
>> +        +        QuotedArticle result = (QuotedArticle) 
>> broker.getObjectByIdentity(id);
>> +        assertNotNull(result);
>> +        assertEquals(result.getArticleName(), ARTICLE_NAME + postfix);
>> +        +        broker.beginTransaction();
>> +        broker.delete(result);
>> +        broker.commitTransaction();
>> +
>> +        broker.clearCache();
>> +        +        QuotedArticle deletedResult = (QuotedArticle) 
>> broker.getObjectByIdentity(id);
>> +        assertNull(deletedResult);
>> +    }
>> +
>> +//    private void deleteProductGroups()
>> +//    {
>> +//        Criteria crit = new Criteria();
>> +//        crit.addLike("groupName", PG_NAME + "%");
>> +//        Query q = QueryFactory.newQuery(ProductGroup.class, crit);
>> +//        broker.deleteByQuery(q);
>> +//    }
>> +//
>> +//    private void deleteArticles()
>> +//    {
>> +//        Criteria crit = new Criteria();
>> +//        crit.addLike("articleName", ARTICLE_NAME + "%");
>> +//        Query q = QueryFactory.newQuery(QuotedArticle.class, crit);
>> +//        broker.deleteByQuery(q);
>> +//    }
>> +
>> +
>> +    //========================================================
>> +    // inner classes / persistent test classes
>> +    //========================================================
>> +
>> +    public static class QuotedArticle
>> +    {
>> +        private Integer articleId;
>> +        private String articleName;
>> +        private double price;
>> +        private InterfaceProductGroup productGroup;
>> +        private int stock;
>> +        private String unit;
>> +
>> +        public QuotedArticle()
>> +        {
>> +        }
>> +
>> +        public Integer getArticleId()
>> +        {
>> +            return articleId;
>> +        }
>> +
>> +        public void setArticleId(Integer articleId)
>> +        {
>> +            this.articleId = articleId;
>> +        }
>> +
>> +        public String getArticleName()
>> +        {
>> +            return articleName;
>> +        }
>> +
>> +        public void setArticleName(String articleName)
>> +        {
>> +            this.articleName = articleName;
>> +        }
>> +
>> +        public InterfaceProductGroup getProductGroup()
>> +        {
>> +            return productGroup;
>> +        }
>> +
>> +        public void setProductGroup(InterfaceProductGroup productGroup)
>> +        {
>> +            this.productGroup = productGroup;
>> +        }
>> +
>> +        public double getPrice()
>> +        {
>> +            return price;
>> +        }
>> +
>> +        public void setPrice(double price)
>> +        {
>> +            this.price = price;
>> +        }
>> +
>> +        public int getStock()
>> +        {
>> +            return stock;
>> +        }
>> +
>> +        public void setStock(int stock)
>> +        {
>> +            this.stock = stock;
>> +        }
>> +
>> +        public String getUnit()
>> +        {
>> +            return unit;
>> +        }
>> +
>> +        public void setUnit(String unit)
>> +        {
>> +            this.unit = unit;
>> +        }
>> +    }
>> +}
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message