db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r526329 - in /db/ojb/branches/OJB_1_0_RELEASE/src: schema/ test/org/apache/ojb/ test/org/apache/ojb/broker/sqlcount/ test/org/apache/ojb/junit/ test/org/apache/ojb/p6spy/
Date Sat, 07 Apr 2007 00:32:14 GMT
Author: arminw
Date: Fri Apr  6 17:32:13 2007
New Revision: 526329

URL: http://svn.apache.org/viewvc?view=rev&rev=526329
Log:
update and add sql-statement count tests

Added:
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/PBCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml
Modified:
    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/sqlcount/AbstractCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AllTests.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/OJBTestCase.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/PBTestCase.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/p6spy/CountLogger.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository.xml

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- 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 Apr  6 17:32:13 2007
@@ -2126,4 +2126,203 @@
 		   type="INTEGER"/>
 	</table>
 
+
+
+    <!-- tables for sql query count tests -->
+    <table name="SQLCOUNT_BOOK">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="TITLE_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="DATE_"
+           type="TIMESTAMP"/>
+        <column
+           name="COVER_"
+           type="LONGVARBINARY"/>
+        <column
+           name="VERSION_"
+           type="INTEGER"/>
+        <column
+           name="FK_PUBLISHER"
+           type="INTEGER"/>
+        <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
+                <reference local="FK_PUBLISHER" foreign="ID_"/>
+        </foreign-key>
+    </table>
+
+    <table name="SQLCOUNT_CD">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="TITLE_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="DATE_"
+           type="TIMESTAMP"/>
+        <column
+           name="COVER_"
+           type="LONGVARBINARY"/>
+        <column
+           name="VERSION_"
+           type="INTEGER"/>
+        <column
+           name="FK_PUBLISHER"
+           type="INTEGER"/>
+        <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
+                <reference local="FK_PUBLISHER" foreign="ID_"/>
+        </foreign-key>
+    </table>
+
+    <table name="SQLCOUNT_DVD">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="TITLE_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="DATE_"
+           type="TIMESTAMP"/>
+        <column
+           name="COVER_"
+           type="LONGVARBINARY"/>
+        <column
+           name="VERSION_"
+           type="INTEGER"/>
+        <column
+           name="FK_PUBLISHER"
+           type="INTEGER"/>
+        <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
+                <reference local="FK_PUBLISHER" foreign="ID_"/>
+        </foreign-key>
+    </table>
+
+    <table name="SQLCOUNT_PUBLICATION">
+        <column
+           name="MEDIUM_ID"
+           type="INTEGER"
+           primaryKey="true"
+           required="true"/>
+        <column
+           name="AUTHOR_ID"
+           type="INTEGER"
+           primaryKey="true"
+           required="true"/>
+        <!--<foreign-key foreignTable="SQLCOUNT_BOOK">-->
+                <!--<reference local="MEDIUM_ID" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+        <!--<foreign-key foreignTable="SQLCOUNT_CD">-->
+                <!--<reference local="MEDIUM_ID" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+        <!--<foreign-key foreignTable="SQLCOUNT_DVD">-->
+                <!--<reference local="MEDIUM_ID" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+        <!--<foreign-key foreignTable="SQLCOUNT_AUTHOR">-->
+                <!--<reference local="AUTHOR_ID" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+    </table>
+
+    <table name="SQLCOUNT_PUBLISHER">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="NAME_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="VERSION_"
+           type="INTEGER"/>
+    </table>
+
+    <table name="SQLCOUNT_AUTHOR">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="NAME_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="VERSION_"
+           type="INTEGER"/>
+        <column
+           name="FK_PUBLISHER"
+           type="INTEGER"/>
+        <column
+           name="FK_AUTHOR_DETAIL"
+           type="INTEGER"/>
+        <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
+                <reference local="FK_PUBLISHER" foreign="ID_"/>
+        </foreign-key>
+    </table>
+
+    <table name="SQLCOUNT_AUTHOR_DETAIL">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="BIO_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="FK_AUTHOR"
+           type="INTEGER"/>
+    </table>
+
+    <table name="SQLCOUNT_REVIEW">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="VOTE_"
+           type="INTEGER"/>
+        <column
+           name="SUMMARY_"
+           type="VARCHAR"
+           size="250"/>
+        <column
+           name="VERSION_"
+           type="INTEGER"/>
+        <column
+           name="FK_AUTHOR"
+           type="INTEGER"/>
+        <column
+           name="FK_MEDIUM"
+           type="INTEGER"/>
+        <foreign-key foreignTable="SQLCOUNT_AUTHOR">
+                <reference local="FK_AUTHOR" foreign="ID_"/>
+        </foreign-key>
+        <!--<foreign-key foreignTable="SQLCOUNT_BOOK">-->
+                <!--<reference local="FK_MEDIUM" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+        <!--<foreign-key foreignTable="SQLCOUNT_CD">-->
+                <!--<reference local="FK_MEDIUM" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+        <!--<foreign-key foreignTable="SQLCOUNT_DVD">-->
+                <!--<reference local="FK_MEDIUM" foreign="ID_"/>-->
+        <!--</foreign-key>-->
+    </table>
+
 </database>

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AbstractCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AbstractCountTest.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AbstractCountTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AbstractCountTest.java Fri Apr  6 17:32:13 2007
@@ -1,25 +1,19 @@
 package org.apache.ojb.broker.sqlcount;
 
-import junit.framework.TestCase;
+import java.io.File;
+
 import com.p6spy.engine.common.P6SpyProperties;
 import com.p6spy.engine.spy.P6SpyDriver;
-import org.apache.ojb.p6spy.CountLogger;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
-import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
-import org.apache.ojb.broker.metadata.MetadataManager;
-import org.apache.ojb.broker.PBKey;
-import org.apache.ojb.broker.PersistenceBrokerFactory;
-import org.apache.ojb.broker.PersistenceBroker;
-import org.apache.ojb.junit.OJBTestCase;
 import org.apache.ojb.junit.PBTestCase;
-
-import java.io.File;
+import org.apache.ojb.p6spy.CountLogger;
 
 /**
- * provides methods to count the number statements.
+ * Provides methods to count the number statements.
  *
- * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
  * @version $Id$
  */
 public abstract class AbstractCountTest extends PBTestCase
@@ -28,6 +22,15 @@
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
     private static final File SPY_PROPS_FILE = new File("testsuite-spy.properties");
 
+    protected AbstractCountTest()
+    {
+    }
+
+    protected AbstractCountTest(String name)
+    {
+        super(name);
+    }
+
     /**
      * sets the spy.properties file name.
      */
@@ -56,7 +59,7 @@
      */
     protected final void assertStmtCount(String msg, int minExpected, int maxExpected)
     {
-        int stmtNum = CountLogger.getSQLStatementCount() - stmtCount;
+        int stmtNum = getStmtCount();
         if(stmtNum > maxExpected)
             fail(msg + ": more SQL statements than expected. Expected: " + maxExpected + ", was: " + stmtNum);
         else if(minExpected > 0 && stmtNum == 0)
@@ -68,6 +71,11 @@
         {
             logStmtCount(msg, stmtNum);
         }
+    }
+
+    protected final int getStmtCount()
+    {
+        return CountLogger.getSQLStatementCount() - stmtCount;
     }
 
     /**

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AllTests.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AllTests.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AllTests.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/AllTests.java Fri Apr  6 17:32:13 2007
@@ -21,7 +21,6 @@
 /**
  * The facade to all TestCases in this package.
  *
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  * @version $Id$
  */
 public class AllTests
@@ -42,6 +41,7 @@
         suite.addTest(new TestSuite(CollectionCountTest.class));
         suite.addTest(new TestSuite(SimpleCountTest.class));
         suite.addTest(new TestSuite(EmptyCacheCountTest.class));
+        suite.addTest(new TestSuite(PBCountTest.class));
         return suite;
     }
 }

Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java?view=auto&rev=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java Fri Apr  6 17:32:13 2007
@@ -0,0 +1,609 @@
+package org.apache.ojb.broker.sqlcount;
+
+/* Copyright 2002-2007 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+import org.apache.ojb.p6spy.CountLogger;
+
+/**
+ * Base count test class with inner test classes.
+ */
+public class BaseCountTest extends AbstractCountTest
+{
+    public BaseCountTest()
+    {
+    }
+
+    public BaseCountTest(String name)
+    {
+        super(name);
+    }
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        String[] excludePattern_1 = new String[]{"select", "max","("};
+        String[] excludePattern_2 = new String[]{"OJB_HL_SEQ"};
+        CountLogger.addExcludePattern(excludePattern_1);
+        CountLogger.addExcludePattern(excludePattern_2);
+    }
+
+    public void tearDown() throws Exception
+    {
+        CountLogger.clearExludePattern();
+        super.tearDown();
+    }
+
+
+    //=======================================================
+    // inner test classes
+    //=======================================================
+
+    public abstract static class Medium implements Serializable
+    {
+        private Integer id;
+        private String title;
+        private Date publicationDate;
+        private byte[] cover;
+        private Integer version;
+        private Integer fkPublisher;
+
+        private List authors;
+        private List reviews;
+        private Publisher publisher;
+
+        public Medium()
+        {
+        }
+
+        public Medium(String title, Date publicationDate, byte[] cover)
+        {
+            this.title = title;
+            this.publicationDate = publicationDate;
+            this.cover = cover;
+        }
+
+        public String toString()
+        {
+            return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                    .append("id", id)
+                    .append("title", title)
+                    .append("publicationDate", publicationDate)
+                    .append("version", version)
+                    .append("fkPublisher", fkPublisher)
+                    .append("cover", cover)
+                    .append("authors.size", authors != null ? authors.size() : 0)
+                    .append("reviews.size", reviews != null ? reviews.size() : 0)
+                    .append("publisher", publisher)
+                    .toString();
+        }
+
+        public void addAuthor(Author author)
+        {
+            if(authors == null)
+            {
+                authors = new ArrayList();
+            }
+            authors.add(author);
+        }
+
+        public void addReview(Review review)
+        {
+            if(reviews == null)
+            {
+                reviews = new ArrayList();
+            }
+            reviews.add(review);
+        }
+
+        public boolean removeReview(Review review)
+        {
+            if(reviews != null) return reviews.remove(review);
+            else return false;
+        }
+
+        public Integer getId()
+        {
+            return id;
+        }
+
+        public void setId(Integer id)
+        {
+            this.id = id;
+        }
+
+        public String getTitle()
+        {
+            return title;
+        }
+
+        public void setTitle(String title)
+        {
+            this.title = title;
+        }
+
+        public Date getPublicationDate()
+        {
+            return publicationDate;
+        }
+
+        public void setPublicationDate(Date publicationDate)
+        {
+            this.publicationDate = publicationDate;
+        }
+
+        public byte[] getCover()
+        {
+            return cover;
+        }
+
+        public void setCover(byte[] cover)
+        {
+            this.cover = cover;
+        }
+
+        public Integer getVersion()
+        {
+            return version;
+        }
+
+        public void setVersion(Integer version)
+        {
+            this.version = version;
+        }
+
+        public List getAuthors()
+        {
+            return authors;
+        }
+
+        public void setAuthors(List authors)
+        {
+            this.authors = authors;
+        }
+
+        public List getReviews()
+        {
+            return reviews;
+        }
+
+        public void setReviews(List reviews)
+        {
+            this.reviews = reviews;
+        }
+
+        public Publisher getPublisher()
+        {
+            return publisher;
+        }
+
+        public void setPublisher(Publisher publisher)
+        {
+            this.publisher = publisher;
+        }
+    }
+
+    public static class Book extends Medium
+    {
+        public Book()
+        {
+        }
+
+        public Book(String title, Date publicationDate, byte[] cover)
+        {
+            super(title, publicationDate, cover);
+        }
+    }
+
+    public static class CD extends Medium
+    {
+        public CD()
+        {
+        }
+
+        public CD(String title, Date publicationDate, byte[] cover)
+        {
+            super(title, publicationDate, cover);
+        }
+    }
+
+    public static class DVD extends Medium
+    {
+        public DVD()
+        {
+        }
+
+        public DVD(String title, Date publicationDate, byte[] cover)
+        {
+            super(title, publicationDate, cover);
+        }
+    }
+
+    public static class Author implements Serializable
+    {
+        private Integer id;
+        private String name;
+        private List media;
+        private Integer version;
+        private Publisher publisher;
+        // use PersistentFieldDirectImpl, no getter/setter required
+        private Integer fkPublisher;
+        private AuthorDetail authorDetail;
+        // use PersistentFieldDirectImpl, no getter/setter required
+        private Integer fkAuthorDetail;
+
+        public Author()
+        {
+        }
+
+        public Author(String name, List books)
+        {
+            this.name = name;
+            this.media = books;
+        }
+
+        public void addMedia(Medium medium)
+        {
+            if(media == null)
+            {
+                media = new ArrayList();
+            }
+            media.add(medium);
+        }
+
+        public Integer getId()
+        {
+            return id;
+        }
+
+        public void setId(Integer id)
+        {
+            this.id = id;
+        }
+
+        public String getName()
+        {
+            return name;
+        }
+
+        public void setName(String name)
+        {
+            this.name = name;
+        }
+
+        public Integer getVersion()
+        {
+            return version;
+        }
+
+        public void setVersion(Integer version)
+        {
+            this.version = version;
+        }
+
+        public List getMedia()
+        {
+            return media;
+        }
+
+        public void setMedia(List media)
+        {
+            this.media = media;
+        }
+
+        public Publisher getPublisher()
+        {
+            return publisher;
+        }
+
+        public void setPublisher(Publisher publisher)
+        {
+            this.publisher = publisher;
+        }
+
+        public AuthorDetail getAuthorDetail()
+        {
+            return authorDetail;
+        }
+
+        public void setAuthorDetail(AuthorDetail authorDetail)
+        {
+            this.authorDetail = authorDetail;
+        }
+    }
+
+    public static interface Publisher extends Serializable
+    {
+        public Integer getId();
+        public void setId(Integer id);
+        public String getName();
+        public void setName(String name);
+        public Integer getVersion();
+        public void setVersion(Integer version);
+        public List getAuthors();
+        public void setAuthors(List authors);
+        public void addAuthor(Author author);
+        public List getMedia();
+        public void setMedia(List media);
+        public void addMedia(Medium m);
+    }
+
+    public static class PublisherImpl implements Publisher
+    {
+        private Integer id;
+        private String name;
+        private Integer version;
+        private List authors;
+        private List media;
+
+        public PublisherImpl()
+        {
+        }
+
+        public PublisherImpl(String name)
+        {
+            this.name = name;
+        }
+
+        public Integer getId()
+        {
+            return id;
+        }
+
+        public void setId(Integer id)
+        {
+            this.id = id;
+        }
+
+        public String getName()
+        {
+            return name;
+        }
+
+        public void setName(String name)
+        {
+            this.name = name;
+        }
+
+        public Integer getVersion()
+        {
+            return version;
+        }
+
+        public void setVersion(Integer version)
+        {
+            this.version = version;
+        }
+
+        public List getAuthors()
+        {
+            return authors;
+        }
+
+        public void setAuthors(List authors)
+        {
+            this.authors = authors;
+        }
+
+        public void addAuthor(Author author)
+        {
+            if(authors == null)
+            {
+                authors = new ArrayList();
+            }
+            if(! authors.contains(author)) authors.add(author);
+        }
+
+        public List getMedia()
+        {
+            return media;
+        }
+
+        public void setMedia(List media)
+        {
+            this.media = media;
+        }
+
+        public void addMedia(Medium m)
+        {
+            if(media == null)
+            {
+                media = new ArrayList();
+            }
+            if(! media.contains(m)) media.add(m);
+        }
+    }
+
+    public static class Review implements Serializable
+    {
+        private Integer id;
+        private Integer vote;
+        private String summary;
+        private Integer fkMedium;
+        private Integer version;
+        private Author author;
+        private Medium medium;
+
+        public Review()
+        {
+        }
+
+        public Review(String summary, Integer vote, Medium medium)
+        {
+            this.summary = summary;
+            this.vote = vote;
+            this.medium = medium;
+        }
+
+        public Review(String summary, Integer vote)
+        {
+            this.summary = summary;
+            this.vote = vote;
+        }
+
+        public Review(String summary)
+        {
+            this.summary = summary;
+        }
+
+        public Integer getId()
+        {
+            return id;
+        }
+
+        public Integer getVote()
+        {
+            return vote;
+        }
+
+        public void setVote(Integer vote)
+        {
+            this.vote = vote;
+        }
+
+        public void setId(Integer id)
+        {
+            this.id = id;
+        }
+
+        public Integer getFkMedium()
+        {
+            return fkMedium;
+        }
+
+        public void setFkMedium(Integer fkMedium)
+        {
+            this.fkMedium = fkMedium;
+        }
+
+        public String getSummary()
+        {
+            return summary;
+        }
+
+        public void setSummary(String summary)
+        {
+            this.summary = summary;
+        }
+
+        public Integer getVersion()
+        {
+            return version;
+        }
+
+        public void setVersion(Integer version)
+        {
+            this.version = version;
+        }
+
+        public Author getAuthor()
+        {
+            return author;
+        }
+
+        public void setAuthor(Author author)
+        {
+            this.author = author;
+        }
+
+        public Medium getMedium()
+        {
+            return medium;
+        }
+
+        public void setMedium(Medium medium)
+        {
+            this.medium = medium;
+        }
+
+        public boolean equals(Object obj)
+        {
+            boolean result = false;
+            if(obj instanceof Review)
+            {
+                Review other = (Review) obj;
+                result = new EqualsBuilder()
+                        .append(id, other.id)
+                        .append(summary, other.summary)
+                        .append(version, other.version)
+                        .append(fkMedium, other.fkMedium)
+                        .append(author, other.author)
+                        .isEquals();
+            }
+            return result;
+        }
+
+        public String toString()
+        {
+            return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE, false);
+        }
+    }
+
+    public static class AuthorDetail implements Serializable
+    {
+        private Integer id;
+        private String bio;
+        // use PersistentFieldDirectImpl, no getter/setter required
+        private Integer fkAuthor;
+        private Author author;
+
+        public AuthorDetail()
+        {
+        }
+
+        public AuthorDetail(String bio)
+        {
+            this.bio = bio;
+        }
+
+        public Integer getId()
+        {
+            return id;
+        }
+
+        public void setId(Integer id)
+        {
+            this.id = id;
+        }
+
+        public String getBio()
+        {
+            return bio;
+        }
+
+        public void setBio(String bio)
+        {
+            this.bio = bio;
+        }
+
+        public Author getAuthor()
+        {
+            return author;
+        }
+
+        public void setAuthor(Author author)
+        {
+            this.author = author;
+        }
+    }
+}

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java Fri Apr  6 17:32:13 2007
@@ -23,9 +23,9 @@
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.ojb.broker.util.ObjectModification;
+import org.apache.ojb.p6spy.CountLogger;
 
 /**
- * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
  * @version $Id$
  */
 public class CollectionCountTest extends AbstractCountTest
@@ -33,10 +33,15 @@
     public void setUp() throws Exception
     {
         super.setUp();
+        String[] excludePattern_1 = new String[]{"select", "max","("};
+        String[] excludePattern_2 = new String[]{"OJB_HL_SEQ"};
+        CountLogger.addExcludePattern(excludePattern_1);
+        CountLogger.addExcludePattern(excludePattern_2);
     }
 
     public void tearDown() throws Exception
     {
+        CountLogger.clearExludePattern();
         super.tearDown();
     }
 
@@ -112,21 +117,17 @@
         broker.clearCache();
         broker.beginTransaction();
         Person pers = new Person();
+        logStmtCount("Storing first person");
         broker.store(pers);
-        //SELECT A0.VERSION,A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  'SEQ_PERSON' ) AND A0.FIELDNAME LIKE  'ID'
-        //SELECT VERSION,GRAB_SIZE,MAX_KEY,FIELDNAME,TABLENAME FROM OJB_HL_SEQ WHERE TABLENAME = 'SEQ_PERSON'  AND FIELDNAME = 'ID'
-        //UPDATE OJB_HL_SEQ SET MAX_KEY='150',GRAB_SIZE='20',VERSION='7' WHERE TABLENAME = 'SEQ_PERSON'  AND FIELDNAME = 'ID'  AND VERSION = '6'
-        // commit|
-        //SELECT LASTNAME,FIRSTNAME,ID FROM PERSON WHERE ID = '131'
-        //INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('131','','')
-        logStmtCount("Storing first person");  // 6. oma: why so many? double lookup in OJB_HL_SEQ !
+        assertStmtCount("insert second Person with empty collection.", 1);
+        logStmtCount("Storing second person");
         resetStmtCount();
         pers = new Person();
         broker.store(pers, ObjectModification.INSERT);
         broker.commitTransaction();
         // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('172','','')
         // commit
-        assertStmtCount("insert second Person with empty collection.", 2);
+        assertStmtCount("insert second Person with empty collection.", 1);
     }
 
     /**
@@ -159,18 +160,12 @@
         new:
         INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('200001','testPersonSingleProjectInsert(1)','')
         INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('200001','testPersonSingleProjectInsert(1)','')
+        // now do real store
         INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('200002','','')
         INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('200002','proj2','')
         INSERT INTO PERSON_PROJECT (PERSON_ID,PROJECT_ID) VALUES ('200002','200002')
         */
-        // old:
-        // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('292','','')
-        // SELECT TITLE,DESCRIPTION,ID FROM PROJECT WHERE ID = '88'
-        // INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('88','proj2','')
-        // SELECT PROJECT_ID FROM PERSON_PROJECT WHERE PERSON_ID='292'      // BRJ: check mn-implementor
-        // INSERT INTO PERSON_PROJECT (PERSON_ID,PROJECT_ID) VALUES ('292','88')
-        // commit|
-        assertStmtCount("insert second Person, singleton collection.", 4);
+        assertStmtCount("insert second Person, singleton collection.", 3);
     }
 
 
@@ -232,7 +227,8 @@
         }
     }
 
-    public void testNonPrefetched()
+    // OJB always use prefetching
+    public void YYYtestNonPrefetched()
     {
         ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
         ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);

Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/PBCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/PBCountTest.java?view=auto&rev=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/PBCountTest.java (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/PBCountTest.java Fri Apr  6 17:32:13 2007
@@ -0,0 +1,837 @@
+package org.apache.ojb.broker.sqlcount;
+
+/* Copyright 2002-2007 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
+import org.apache.ojb.broker.metadata.CollectionDescriptor;
+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.broker.util.ObjectModification;
+
+/**
+ * Test the number of executed query statements when using the PB-api.
+ */
+public class PBCountTest extends BaseCountTest
+{
+    public void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /*
+    ojbChangeReferenceSetting(PublisherImpl.class,
+                "media", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                true);
+    */
+
+    public void testOneToOne()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // disable the bidirectional 1:1 reference for this test
+        ojbChangeReferenceSetting(AuthorDetail.class,
+                "author", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        String appendix = ojbTestMethodIdentifier();
+        Author author = new Author("author_1" + appendix, null);
+        AuthorDetail detail = new AuthorDetail("detail_1" + appendix);
+        author.setAuthorDetail(detail);
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(author, ObjectModification.INSERT);
+        broker.commitTransaction();
+        assertStmtCount("insert stmt count", 2);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Author.class, new Criteria().addEqualTo("name", "author_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        assertEquals(1, result.size());
+        assertNotNull(((Author) result.get(0)).getAuthorDetail());
+        // this only works with enabled proxy
+        assertStmtCount("query 1:1", 1);
+    }
+
+    public void testOneToOneBidirectional()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        String appendix = ojbTestMethodIdentifier();
+        Author author = new Author("author_1" + appendix, null);
+        AuthorDetail detail = new AuthorDetail("detail_1" + appendix);
+        author.setAuthorDetail(detail);
+        detail.setAuthor(author);
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(author, ObjectModification.INSERT, true);
+        broker.store(author, ObjectModification.UPDATE);
+        broker.commitTransaction();
+        assertStmtCount("insert stmt count", 3);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Author.class, new Criteria().addEqualTo("name", "author_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        assertEquals(1, result.size());
+        assertNotNull(((Author) result.get(0)).getAuthorDetail());
+        // this only works with enabled proxy
+        assertStmtCount("query 1:1", 1);
+    }
+
+    public void testOneToN()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // disable back-reference
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        String appendix = ojbTestMethodIdentifier();
+        Publisher publisher = new PublisherImpl("publisher_1" + appendix);
+        Author[] arr = new Author[6];
+        arr[0] = new Author("author_1" + appendix, null);
+        arr[1] = new Author("author_2" + appendix, null);
+        arr[2] = new Author("author_3" + appendix, null);
+        arr[3] = new Author("author_4" + appendix, null);
+        arr[4] = new Author("author_5" + appendix, null);
+        arr[5] = new Author("author_6" + appendix, null);
+        for(int i = 0; i < arr.length; i++)
+        {
+            Author author = arr[i];
+            publisher.addAuthor(author);
+        }
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(publisher, ObjectModification.INSERT);
+        broker.commitTransaction();
+        assertStmtCount("insert 1:n", 7);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Publisher.class, new Criteria().addEqualTo("name", "publisher_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        // enabled proxy
+        assertStmtCount("query 1:n", 1);
+        assertEquals(1, result.size());
+        assertNotNull(((Publisher) result.get(0)).getAuthors());
+        assertEquals(6, ((Publisher) result.get(0)).getAuthors().size());
+    }
+
+    public void testOneToN_2()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // disable back-reference
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // disable proxy
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        String appendix = ojbTestMethodIdentifier();
+        Publisher publisher = new PublisherImpl("publisher_1" + appendix);
+        Author[] arr = new Author[6];
+        arr[0] = new Author("author_1" + appendix, null);
+        arr[1] = new Author("author_2" + appendix, null);
+        arr[2] = new Author("author_3" + appendix, null);
+        arr[3] = new Author("author_4" + appendix, null);
+        arr[4] = new Author("author_5" + appendix, null);
+        arr[5] = new Author("author_6" + appendix, null);
+        for(int i = 0; i < arr.length; i++)
+        {
+            Author author = arr[i];
+            publisher.addAuthor(author);
+        }
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(publisher, ObjectModification.INSERT);
+        broker.commitTransaction();
+        assertStmtCount("insert 1:n", 7);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Publisher.class, new Criteria().addEqualTo("name", "publisher_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        // disabled proxy
+        assertStmtCount("query 1:n", 2);
+        assertEquals(1, result.size());
+        assertNotNull(((Publisher) result.get(0)).getAuthors());
+        assertEquals(6, ((Publisher) result.get(0)).getAuthors().size());
+    }
+
+    public void testOneToNBidirectional()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // enable back-reference
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        String appendix = ojbTestMethodIdentifier();
+        Publisher publisher = new PublisherImpl("publisher_1" + appendix);
+        Author[] arr = new Author[6];
+        arr[0] = new Author("author_1" + appendix, null);
+        arr[1] = new Author("author_2" + appendix, null);
+        arr[2] = new Author("author_3" + appendix, null);
+        arr[3] = new Author("author_4" + appendix, null);
+        arr[4] = new Author("author_5" + appendix, null);
+        arr[5] = new Author("author_6" + appendix, null);
+        for(int i = 0; i < arr.length; i++)
+        {
+            Author author = arr[i];
+            publisher.addAuthor(author);
+            author.setPublisher(publisher);
+        }
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(publisher, ObjectModification.INSERT);
+        broker.commitTransaction();
+        assertStmtCount("insert 1:n", 7);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Publisher.class, new Criteria().addEqualTo("name", "publisher_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        // enabled proxy
+        assertStmtCount("query 1:n", 1);
+        assertEquals(1, result.size());
+        List authors = ((Publisher) result.get(0)).getAuthors();
+        assertNotNull(authors);
+        assertEquals(6, authors.size());
+        for(int i = 0; i < authors.size(); i++)
+        {
+            Author a =  (Author) authors.get(i);
+            assertNotNull(a.getPublisher());
+            assertEquals(publisher.getId(), a.getPublisher().getId());
+        }
+    }
+
+    public void testOneToNBidirectional_2()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // enable back-reference
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        // disable proxy
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        String appendix = ojbTestMethodIdentifier();
+        Publisher publisher = new PublisherImpl("publisher_1" + appendix);
+        Author[] arr = new Author[6];
+        arr[0] = new Author("author_1" + appendix, null);
+        arr[1] = new Author("author_2" + appendix, null);
+        arr[2] = new Author("author_3" + appendix, null);
+        arr[3] = new Author("author_4" + appendix, null);
+        arr[4] = new Author("author_5" + appendix, null);
+        arr[5] = new Author("author_6" + appendix, null);
+        for(int i = 0; i < arr.length; i++)
+        {
+            Author author = arr[i];
+            publisher.addAuthor(author);
+            author.setPublisher(publisher);
+        }
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(publisher, ObjectModification.INSERT);
+        broker.commitTransaction();
+        assertStmtCount("insert 1:n", 7);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Publisher.class, new Criteria().addEqualTo("name", "publisher_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        assertEquals(1, result.size());
+        List authors = ((Publisher) result.get(0)).getAuthors();
+        assertNotNull(authors);
+        assertEquals(6, authors.size());
+        for(int i = 0; i < authors.size(); i++)
+        {
+            Author a =  (Author) authors.get(i);
+            assertNotNull(a.getPublisher());
+            assertEquals(publisher.getId(), a.getPublisher().getId());
+        }
+        // disabled proxy
+        assertStmtCount("query 1:n", 2);
+    }
+
+    public void testOneToNBidirectional_3()
+    {
+        // disable the m:n reference for this test
+        ojbChangeReferenceSetting(Author.class,
+                "media", false,
+                CollectionDescriptor.CASCADE_NONE,
+                CollectionDescriptor.CASCADE_NONE,
+                false);
+        // enable back-reference with proxy
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                true);
+        // enable proxy
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                true);
+        String appendix = ojbTestMethodIdentifier();
+        Publisher publisher = new PublisherImpl("publisher_1" + appendix);
+        Author[] arr = new Author[6];
+        arr[0] = new Author("author_1" + appendix, null);
+        arr[1] = new Author("author_2" + appendix, null);
+        arr[2] = new Author("author_3" + appendix, null);
+        arr[3] = new Author("author_4" + appendix, null);
+        arr[4] = new Author("author_5" + appendix, null);
+        arr[5] = new Author("author_6" + appendix, null);
+        for(int i = 0; i < arr.length; i++)
+        {
+            Author author = arr[i];
+            publisher.addAuthor(author);
+            author.setPublisher(publisher);
+        }
+
+        resetStmtCount();
+        broker.beginTransaction();
+        broker.store(publisher, ObjectModification.INSERT);
+        broker.commitTransaction();
+        assertStmtCount("insert 1:n", 7);
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Publisher.class, new Criteria().addEqualTo("name", "publisher_1" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        assertEquals(1, result.size());
+        List authors = ((Publisher) result.get(0)).getAuthors();
+        assertNotNull(authors);
+        assertStmtCount("query 1:n", 1);
+        assertEquals(6, authors.size());
+        for(int i = 0; i < authors.size(); i++)
+        {
+            Author a =  (Author) authors.get(i);
+            assertNotNull(a.getPublisher());
+            assertEquals(publisher.getId(), a.getPublisher().getId());
+        }
+        // materialize proxy
+        assertStmtCount("query 1:n", 3);
+    }
+
+    public void testMToN()
+    {
+        ojbChangeReferenceSetting(Author.class,
+                "media", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                true);
+        ojbChangeReferenceSetting(Book.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                true);
+        ojbChangeReferenceSetting(CD.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                true);
+
+        String appendix = ojbTestMethodIdentifier();
+        Book b1 = new Book("book_1" + appendix, new Date(), null);
+        Book b2 = new Book("book_2" + appendix, new Date(), null);
+        CD cd1 = new CD("cd_1" + appendix, new Date(), null);
+        Author author_1 = new Author("author_1" + appendix, null);
+        Author author_2 = new Author("author_2" + appendix, null);
+
+        author_1.addMedia(b1);
+        b1.addAuthor(author_1);
+        author_1.addMedia(b2);
+        b2.addAuthor(author_1);
+        author_1.addMedia(cd1);
+        cd1.addAuthor(author_1);
+
+        author_2.addMedia(cd1);
+        cd1.addAuthor(author_2);
+
+        resetStmtCount();
+        broker.beginTransaction();
+        // this store all objects
+        broker.store(b1, ObjectModification.INSERT);
+        assertStmtCount("insert m:n", 9);
+        broker.commitTransaction();
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Medium.class, new Criteria().addLike("title", "%" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        assertEquals(3, result.size());
+        // with proxy enabled
+        assertStmtCount("query m:n", 3);
+        boolean match = false;
+        for(int i = 0; i < result.size(); i++)
+        {
+            Medium m = (Medium) result.get(i);
+            if(m instanceof CD)
+            {
+                List authors = m.getAuthors();
+                assertEquals(2, authors.size());
+                match = true;
+            }
+            else
+            {
+                assertNotNull(m.getAuthors());
+                assertTrue(m.getAuthors().size() == 1);
+            }
+        }
+        assertTrue("Wrong objects received?", match);
+    }
+
+    public void testMToN_2()
+    {
+        ojbChangeReferenceSetting(Author.class,
+                "media", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Book.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(CD.class,
+                "authors", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+
+        String appendix = ojbTestMethodIdentifier();
+        Book b1 = new Book("book_1" + appendix, new Date(), null);
+        Book b2 = new Book("book_2" + appendix, new Date(), null);
+        CD cd1 = new CD("cd_1" + appendix, new Date(), null);
+        Author author_1 = new Author("author_1" + appendix, null);
+        Author author_2 = new Author("author_2" + appendix, null);
+
+        author_1.addMedia(b1);
+        b1.addAuthor(author_1);
+        author_1.addMedia(b2);
+        b2.addAuthor(author_1);
+        author_1.addMedia(cd1);
+        cd1.addAuthor(author_1);
+
+        author_2.addMedia(cd1);
+        cd1.addAuthor(author_2);
+
+        resetStmtCount();
+        broker.beginTransaction();
+        // this store all objects
+        broker.store(b1, ObjectModification.INSERT);
+        assertStmtCount("insert m:n", 9);
+        broker.commitTransaction();
+
+        resetStmtCount();
+        broker.clearCache();
+        Query query = QueryFactory.newQuery(Medium.class, new Criteria().addLike("title", "%" + appendix));
+        List result = new ArrayList(broker.getCollectionByQuery(query));
+        assertEquals(3, result.size());
+        // with proxy disabled
+        assertStmtCount("query m:n", 13);
+        boolean match = false;
+        for(int i = 0; i < result.size(); i++)
+        {
+            Medium m = (Medium) result.get(i);
+            if(m instanceof CD)
+            {
+                List authors = m.getAuthors();
+                assertEquals(2, authors.size());
+                match = true;
+            }
+            else
+            {
+                assertNotNull(m.getAuthors());
+                assertTrue(m.getAuthors().size() == 1);
+            }
+        }
+        assertTrue("Wrong objects received?", match);
+    }
+
+
+
+    protected void insertTestData_2(String appendix)
+    {
+        Publisher p2 = new PublisherImpl("publisher_2" + appendix);
+        Medium[] arr = new Medium[6];
+        arr[0] = new Book("book_2" + appendix, new Date(1), null);
+        arr[1] = new CD("CD_1" + appendix, new Date(1), null);
+        arr[2] = new CD("CD_2" + appendix, new Date(1), null);
+        arr[3] = new CD("CD_3" + appendix, new Date(1), null);
+        arr[4] = new DVD("DVD_1" + appendix, new Date(1), null);
+        arr[5] = new DVD("DVD_2" + appendix, new Date(1), null);
+        for(int i = 0; i < arr.length; i++)
+        {
+            Medium medium = arr[i];
+            p2.addMedia(medium);
+            medium.setPublisher(p2);
+        }
+        broker.beginTransaction();
+        broker.store(p2, ObjectModification.INSERT);
+        broker.commitTransaction();
+    }
+
+    protected void deleteTestData_2(String appendix)
+    {
+        //broker.serviceConnectionManager().setBatchMode(false);
+        broker.beginTransaction();
+        Query q = QueryFactory.newQuery(Publisher.class, new Criteria().addLike("name", "%"+appendix));
+        List publisher = new ArrayList(broker.getCollectionByQuery(q));
+        for(int i = 0; i < publisher.size(); i++)
+        {
+            Object o =  publisher.get(i);
+            broker.delete(o);
+        }
+        broker.commitTransaction();
+    }
+
+    protected void insertTestData_1(String appendix)
+    {
+        Book m1 = new Book("book_1" + appendix, new Date(1), null);
+        Author a1 = new Author("author_1" + appendix, null);
+        Author a2 = new Author("author_2" + appendix, null);
+        Author a3 = new Author("author_3" + appendix, null);
+        Author a4 = new Author("author_4" + appendix, null);
+        Publisher p1 = new PublisherImpl("publisher_1" + appendix);
+
+        p1.addAuthor(a1);
+        p1.addAuthor(a2);
+        p1.addAuthor(a3);
+        p1.addAuthor(a4);
+        a1.setPublisher(p1);
+        a2.setPublisher(p1);
+        a3.setPublisher(p1);
+        a4.setPublisher(p1);
+
+        List reviews = new ArrayList();
+        for(int i=0; i<3; i++)
+        {
+            Review rev = new Review("review" + i  + appendix, new Integer(10 * i));
+            rev.setAuthor(new Author("review_author_" + i + appendix, null));
+            rev.setMedium(m1);
+            reviews.add(rev);
+        }
+        m1.setReviews(reviews);
+        a1.addMedia(m1);
+        m1.addAuthor(a1);
+        m1.setPublisher(p1);
+
+        broker.beginTransaction();
+        // it's a circular object graph, so insert the plain start object first
+        // and then update it with all references
+        broker.store(m1, ObjectModification.INSERT, true);
+        broker.serviceConnectionManager().executeBatch();
+        broker.store(m1);
+        broker.commitTransaction();
+    }
+
+    protected void deleteTestData_1(String appendix)
+    {
+        //broker.serviceConnectionManager().setBatchMode(false);
+        broker.beginTransaction();
+        Query q = QueryFactory.newQuery(Medium.class, new Criteria().addLike("title", "%"+appendix));
+        List media = new ArrayList(broker.getCollectionByQuery(q));
+        assertEquals(1, media.size());
+        for(int i = 0; i < media.size(); i++)
+        {
+            Object o =  media.get(i);
+            broker.delete(o);
+        }
+        broker.commitTransaction();
+    }
+
+    public void testInsert_1() throws Exception
+    {
+        String appendix = ojbTestMethodIdentifier();
+
+        resetStmtCount();
+        insertTestData_1(appendix);
+        assertStmtCount("Test data insert stmt count", 24);
+
+        appendix = "_testInsert_1_" + System.currentTimeMillis();
+        resetStmtCount();
+        insertTestData_1(appendix);
+        assertStmtCount("Test data insert stmt count", 24);
+    }
+
+    public void testDelete_1() throws Exception
+    {
+        String appendix = ojbTestMethodIdentifier();
+        insertTestData_1(appendix);
+
+        resetStmtCount();
+        deleteTestData_1(appendix);
+        assertStmtCount("Test data delete stmt count", 51);
+    }
+
+    public void testDelete_1b() throws Exception
+    {
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "media", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "authors", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Author.class,
+                "media", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Book.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Book.class,
+                "reviews", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(CD.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(CD.class,
+                "reviews", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(DVD.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(DVD.class,
+                "reviews", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Review.class,
+                "author", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Review.class,
+                "medium", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        refreshBroker();
+
+        String appendix = ojbTestMethodIdentifier();
+        insertTestData_1(appendix);
+
+        Thread.sleep(200);
+        resetStmtCount();
+        deleteTestData_1(appendix);
+        assertStmtCount("Test data delete stmt count", 42);
+    }
+
+    public void testInsert_2()
+    {
+        String appendix = ojbTestMethodIdentifier();
+
+        resetStmtCount();
+        insertTestData_2(appendix);
+        assertStmtCount("Test data insert stmt count", 7);
+    }
+
+    public void testDelete_2()
+    {
+        String appendix = ojbTestMethodIdentifier();
+
+        insertTestData_2(appendix);
+
+        resetStmtCount();
+        deleteTestData_2(appendix);
+        assertStmtCount("Test data delete stmt count", 30);
+    }
+
+    public void testDelete_2b()
+    {
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "media", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(PublisherImpl.class,
+                "authors", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Author.class,
+                "media", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Author.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Book.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Book.class,
+                "reviews", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(CD.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(CD.class,
+                "reviews", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(DVD.class,
+                "publisher", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(DVD.class,
+                "reviews", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Review.class,
+                "author", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Review.class,
+                "medium", true,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                ObjectReferenceDescriptor.CASCADE_OBJECT,
+                false);
+        refreshBroker();
+
+        String appendix = ojbTestMethodIdentifier();
+
+        insertTestData_2(appendix);
+
+        resetStmtCount();
+        deleteTestData_2(appendix);
+        assertStmtCount("Test data delete stmt count", 27);
+    }
+
+    public void testObjectWithOneToN()
+    {
+        String appendix = ojbTestMethodIdentifier();
+        insertTestData_2(appendix);
+
+        resetStmtCount();
+        broker.clearCache();
+        broker.beginTransaction();
+        Query qry = QueryFactory.newQuery(Publisher.class, new Criteria().addEqualTo("name", "publisher_2" + appendix));
+        assertStmtCount("preparation", 0);
+        Iterator iter = broker.getIteratorByQuery(qry);
+        assertStmtCount("getIteratorByQuery", 1);
+        while(iter.hasNext())
+        {
+            resetStmtCount();
+            Publisher next = (Publisher) iter.next();
+            assertStmtCount("next", 0);
+            List list = next.getMedia();
+            assertNotNull(list);
+            list.get(0);
+            assertStmtCount("getMedia", 3);
+            assertEquals(6, list.size());
+        }
+        broker.commitTransaction();
+
+        deleteTestData_2(appendix);
+    }
+}

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java Fri Apr  6 17:32:13 2007
@@ -6,7 +6,6 @@
 import org.apache.ojb.broker.Person;
 
 /**
- * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
  * @version $Id$
  */
 public class SimpleCountTest extends AbstractCountTest
@@ -48,7 +47,7 @@
         logger.info("comitting txn");
         // COMMIT
         broker.commitTransaction();
-        assertStmtCount("retrieve Person by Identity", 4);
+        assertStmtCount("retrieve Person by Identity", 3);
     }
 
     public void testRetrievePersonTwice()

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/OJBTestCase.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/OJBTestCase.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/OJBTestCase.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/OJBTestCase.java Fri Apr  6 17:32:13 2007
@@ -64,6 +64,19 @@
     }
 
     /**
+     * Returns a string based identifier for the current test compounded by
+     * test method name and current system time:
+     * <br/>
+     * _testMethodName_123349886_
+     *
+     * @return A string based test method identifier.
+     */
+    public String ojbTestMethodIdentifier()
+    {
+        return "_" + getName() + "_" + System.currentTimeMillis() + "_";
+    }
+
+    /**
      * Sleep current thread for a minimal period.
      */
     public void ojbSleep()

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/PBTestCase.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/PBTestCase.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/PBTestCase.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/junit/PBTestCase.java Fri Apr  6 17:32:13 2007
@@ -24,7 +24,6 @@
  * A base class for PB-api based test cases.
  * NOTE: The PB instance is declared <tt>public</tt> (no getter/setter) for easy use.
  *
- * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
  * @version $Id$
  */
 public class PBTestCase extends OJBTestCase
@@ -70,6 +69,22 @@
     }
 
     /**
+     * Refresh the current used broker instance with a new one.
+     */
+    public void refreshBroker()
+    {
+        if(broker != null)
+        {
+            if(broker.isInTransaction())
+            {
+                broker.abortTransaction();
+            }
+            broker.close();
+        }
+        assertNotNull(broker = PersistenceBrokerFactory.defaultPersistenceBroker());
+    }
+
+    /**
      * Returns the platform implementation class name of the currently
      * used broker.
      * @return platform implementation class name
@@ -98,11 +113,6 @@
         catch (PersistenceBrokerException pbe)
         {
             throw pbe;
-        }
-        catch (ClassCastException cce)
-        {
-            System.err.println("Error in JDBC-driver while storing: " + obj);
-            throw cce;
         }
         finally
         {

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/p6spy/CountLogger.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/p6spy/CountLogger.java?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/p6spy/CountLogger.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/p6spy/CountLogger.java Fri Apr  6 17:32:13 2007
@@ -4,55 +4,137 @@
  */
 package org.apache.ojb.p6spy;
 
-import com.p6spy.engine.logging.appender.P6Logger;
-import com.p6spy.engine.logging.appender.FileLogger;
-
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
 
+import com.p6spy.engine.logging.appender.FileLogger;
+import com.p6spy.engine.logging.appender.P6Logger;
+import org.apache.commons.lang.StringUtils;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 
 /**
  * Use this class in order to log and count jdbc statements
  *
- * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
  * @version $Id$
  */
 public class CountLogger extends FileLogger implements P6Logger
 {
-  protected String lastEntry;
-  private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    private static List excludePatterns = new ArrayList();
+
+    protected String lastEntry;
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private static int countSQL;
+
+    public CountLogger()
+    {
+        logger.debug("start logging");
+    }
+
+    /**
+     * count the statements in case counting is enabled.
+     *
+     * @see com.p6spy.engine.logging.appender.FormattedLogger#logSQL
+     */
+    public void logSQL(int i, String s, long l, String s1, String s2, String s3)
+    {
+        if(s.equals("resultset"))
+        {
+            // BRJ: p6spy workaround
+            // resultset cannot be excluded using p6spy properties
+            return;
+        }
+        super.logSQL(i, s, l, s1, s2, s3);
+        //System.out.println("s=" + s + " s1=" +s1 + " s2=" + s2 + " s3=" + s3);
+        countEvent(s1, s3);
+    }
 
-  private static int countSQL;
+    protected void countEvent(String type, String sql)
+    {
+        boolean count = false;
+        if(type.equalsIgnoreCase("statement"))
+        {
+            if(excludePatterns.size() > 0)
+            {
+                for(int i = 0; i < excludePatterns.size(); i++)
+                {
+                    String[] strings = (String[]) excludePatterns.get(i);
+                    if(toExclude(sql, strings))
+                    {
+                        count = false;
+                        break;
+                    }
+                    else
+                    {
+                        count = true;
+                    }
+                }
+            }
+            else
+            {
+                count = true;
+            }
+        }
+        else
+        {
+            if(!StringUtils.isBlank(sql))
+            {
+                count = true;
+            }
+        }
+        if(count)
+        {
+            countSQL++;
+        }
+    }
 
-  public CountLogger()
-  {
-    logger.debug("start logging");
-  }
-
-  /**
-   * count the statements in case counting is enabled.
-   *
-   * @see com.p6spy.engine.logging.appender.FormattedLogger#logSQL
-   */
-  public void logSQL(int i, String s, long l, String s1, String s2, String s3)
-  {  
-    if (s1.equals("resultset"))
-    {
-        // BRJ: p6spy workaround 
-        // resultset cannot be excluded using p6spy properties
-        return;
-    }
-    
-    super.logSQL(i, s, l, s1, s2, s3);
-    countSQL++;
-    logger.info("sql: " + s1 + "|" + s3);
-  }
-
-  /**
-   * @return the number of statements issued so far.
-   */
-  public static int getSQLStatementCount()
-  {
-    return countSQL;
-  }
+    /**
+     * Exclude statements from sql count (e.g. roundup to a high/low-sequence table).
+     * Add an array of keywords in the correct order, e.g. ["select", "max", "("] to exclude
+     * all "select max(..." statements.
+     */
+    public static void addExcludePattern(String[] pattern)
+    {
+        excludePatterns.add(pattern);
+    }
+
+    public static void clearExludePattern()
+    {
+        excludePatterns.clear();
+    }
+
+    protected boolean toExclude(String sql, String[] pattern)
+    {
+        boolean result;
+        StringTokenizer tokenizer = new StringTokenizer(sql, "( ),+-/*", true);
+        int index = 0;
+        int limit = pattern.length;
+        while(tokenizer.hasMoreTokens() && index < limit)
+        {
+            String match = pattern[index];
+            String token = tokenizer.nextToken();
+            if(StringUtils.isBlank(token))
+            {
+                continue;
+            }
+            //System.out.println("token: " + token);
+            result = match.equalsIgnoreCase(token);
+            if(result)
+            {
+                ++index;
+            }
+        }
+        result = index > 0 && index == limit;
+        return result;
+    }
+
+    /**
+     * @return the number of statements issued so far.
+     */
+    public static int getSQLStatementCount()
+    {
+        return countSQL;
+    }
 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository.xml?view=diff&rev=526329&r1=526328&r2=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository.xml (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository.xml Fri Apr  6 17:32:13 2007
@@ -51,6 +51,7 @@
 <!ENTITY junit_inheritance SYSTEM "repository_junit_inheritance.xml">
 <!ENTITY junit_pathClass SYSTEM "repository_junit_pathClass.xml">
 <!ENTITY junit_pagination SYSTEM "repository_junit_pagination.xml">
+<!ENTITY junit_sqlcount SYSTEM "repository_junit_sqlcount.xml">
 
 <!ENTITY user SYSTEM "repository_user.xml">
 <!ENTITY ejb SYSTEM "repository_ejb.xml">
@@ -85,6 +86,7 @@
     &junit_inheritance;
     &junit_pathClass;
     &junit_pagination;
+    &junit_sqlcount;
 
     <!-- include mappings for the EJB-examples, comment in before run
      the ejb-example tests -->

Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml?view=auto&rev=526329
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml Fri Apr  6 17:32:13 2007
@@ -0,0 +1,483 @@
+
+<!-- =================================================== -->
+<!--     Mapping for sqlcount tests                      -->
+<!-- =================================================== -->
+<class-descriptor class="org.apache.ojb.broker.sqlcount.BaseCountTest$Medium">
+    <extent-class class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Book"/>
+    <extent-class class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$CD"/>
+    <extent-class class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$DVD"/>
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$Book"
+    table="SQLCOUNT_BOOK"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="title"
+        column="TITLE_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="publicationDate"
+        column="DATE_"
+        jdbc-type="TIMESTAMP"
+        conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion"
+        />
+
+    <field-descriptor
+        name="cover"
+        column="COVER_"
+        jdbc-type="LONGVARBINARY"
+        />
+
+    <field-descriptor
+        name="version"
+        column="VERSION_"
+        jdbc-type="INTEGER"
+        locking="true"
+        />
+
+    <field-descriptor
+        name="fkPublisher"
+        column="FK_PUBLISHER"
+        jdbc-type="INTEGER"
+        field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
+        />
+
+    <reference-descriptor name="publisher"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkPublisher"/>
+    </reference-descriptor>
+
+    <collection-descriptor
+        name="reviews"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <orderby name="fkMedium" sort="ASC"/>
+        <inverse-foreignkey field-ref="fkMedium"/>
+    </collection-descriptor>
+
+    <collection-descriptor
+        name="authors"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+        indirection-table="SQLCOUNT_PUBLICATION"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <fk-pointing-to-this-class column="MEDIUM_ID"/>
+        <fk-pointing-to-element-class column="AUTHOR_ID"/>
+    </collection-descriptor>
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$CD"
+    table="SQLCOUNT_CD"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="title"
+        column="TITLE_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="publicationDate"
+        column="DATE_"
+        jdbc-type="TIMESTAMP"
+        conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion"
+        />
+
+    <field-descriptor
+        name="cover"
+        column="COVER_"
+        jdbc-type="LONGVARBINARY"
+        />
+
+    <field-descriptor
+        name="version"
+        column="VERSION_"
+        jdbc-type="INTEGER"
+        locking="true"
+        />
+
+    <field-descriptor
+        name="fkPublisher"
+        column="FK_PUBLISHER"
+        jdbc-type="INTEGER"
+        field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
+        />
+
+    <reference-descriptor name="publisher"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkPublisher"/>
+    </reference-descriptor>
+
+    <collection-descriptor
+        name="reviews"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <orderby name="fkMedium" sort="ASC"/>
+        <inverse-foreignkey field-ref="fkMedium"/>
+    </collection-descriptor>
+
+    <collection-descriptor
+        name="authors"
+        collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+        indirection-table="SQLCOUNT_PUBLICATION"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <fk-pointing-to-this-class column="MEDIUM_ID"/>
+        <fk-pointing-to-element-class column="AUTHOR_ID"/>
+    </collection-descriptor>
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$DVD"
+    table="SQLCOUNT_DVD"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="title"
+        column="TITLE_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="publicationDate"
+        column="DATE_"
+        jdbc-type="TIMESTAMP"
+        conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion"
+        />
+
+    <field-descriptor
+        name="cover"
+        column="COVER_"
+        jdbc-type="LONGVARBINARY"
+        />
+
+    <field-descriptor
+        name="version"
+        column="VERSION_"
+        jdbc-type="INTEGER"
+        locking="true"
+        />
+
+    <field-descriptor
+        name="fkPublisher"
+        column="FK_PUBLISHER"
+        jdbc-type="INTEGER"
+        field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
+        />
+
+    <reference-descriptor name="publisher"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkPublisher"/>
+    </reference-descriptor>
+
+    <collection-descriptor
+        name="reviews"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <orderby name="fkMedium" sort="ASC"/>
+        <inverse-foreignkey field-ref="fkMedium"/>
+    </collection-descriptor>
+
+    <collection-descriptor
+        name="authors"
+        collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+        indirection-table="SQLCOUNT_PUBLICATION"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <fk-pointing-to-this-class column="MEDIUM_ID"/>
+        <fk-pointing-to-element-class column="AUTHOR_ID"/>
+    </collection-descriptor>
+</class-descriptor>
+
+<class-descriptor class="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher">
+    <extent-class class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$PublisherImpl"/>
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$PublisherImpl"
+    table="SQLCOUNT_PUBLISHER"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="name"
+        column="NAME_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="version"
+        column="VERSION_"
+        jdbc-type="INTEGER"
+        locking="true"
+        />
+
+    <collection-descriptor
+        name="authors"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <inverse-foreignkey field-ref="fkPublisher"/>
+    </collection-descriptor>
+
+    <collection-descriptor
+        name="media"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Medium"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <inverse-foreignkey field-ref="fkPublisher"/>
+    </collection-descriptor>
+
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+    table="SQLCOUNT_AUTHOR"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="name"
+        column="NAME_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="version"
+        column="VERSION_"
+        jdbc-type="INTEGER"
+        locking="true"
+        />
+
+    <field-descriptor
+        name="fkPublisher"
+        column="FK_PUBLISHER"
+        jdbc-type="INTEGER"
+        field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
+    />
+
+    <field-descriptor
+        name="fkAuthorDetail"
+        column="FK_AUTHOR_DETAIL"
+        jdbc-type="INTEGER"
+        field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
+    />
+
+    <reference-descriptor name="publisher"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkPublisher"/>
+    </reference-descriptor>
+
+    <reference-descriptor name="authorDetail"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$AuthorDetail"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkAuthorDetail"/>
+    </reference-descriptor>
+
+    <collection-descriptor
+        name="media"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Medium"
+        indirection-table="SQLCOUNT_PUBLICATION"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <fk-pointing-to-this-class column="AUTHOR_ID"/>
+        <fk-pointing-to-element-class column="MEDIUM_ID"/>
+    </collection-descriptor>
+
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$AuthorDetail"
+    table="SQLCOUNT_AUTHOR_DETAIL"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="bio"
+        column="BIO_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="fkAuthor"
+        column="FK_AUTHOR"
+        jdbc-type="INTEGER"
+        field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
+    />
+
+    <reference-descriptor name="author"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkAuthor"/>
+    </reference-descriptor>
+</class-descriptor>
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
+    table="SQLCOUNT_REVIEW"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="vote"
+        column="VOTE_"
+        jdbc-type="INTEGER"
+        />
+
+    <field-descriptor
+        name="summary"
+        column="SUMMARY_"
+        jdbc-type="VARCHAR"
+        />
+
+    <field-descriptor
+        name="version"
+        column="VERSION_"
+        jdbc-type="INTEGER"
+        locking="true"
+        />
+
+    <field-descriptor
+        name="fkAuthor"
+        column="FK_AUTHOR"
+        jdbc-type="INTEGER"
+        access="anonymous"
+        />
+
+    <field-descriptor
+        name="fkMedium"
+        column="FK_MEDIUM"
+        jdbc-type="INTEGER"
+        />
+
+    <reference-descriptor name="author"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkAuthor"/>
+    </reference-descriptor>
+
+    <reference-descriptor name="medium"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Medium"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkMedium"/>
+    </reference-descriptor>
+
+</class-descriptor>
\ No newline at end of file



---------------------------------------------------------------------
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