Return-Path: Mailing-List: contact ojb-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ojb-dev@jakarta.apache.org Received: (qmail 73517 invoked by uid 500); 31 Jan 2003 17:42:46 -0000 Received: (qmail 73513 invoked from network); 31 Jan 2003 17:42:46 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 31 Jan 2003 17:42:46 -0000 Received: (qmail 89834 invoked by uid 1510); 31 Jan 2003 17:42:45 -0000 Date: 31 Jan 2003 17:42:45 -0000 Message-ID: <20030131174245.89833.qmail@icarus.apache.org> From: arminw@apache.org To: jakarta-ojb-cvs@apache.org Subject: cvs commit: jakarta-ojb/xdocs faq.xml performance.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N arminw 2003/01/31 09:42:45 Modified: xdocs faq.xml performance.xml Log: add more faq, correct document view Revision Changes Path 1.13 +274 -11 jakarta-ojb/xdocs/faq.xml Index: faq.xml =================================================================== RCS file: /home/cvs/jakarta-ojb/xdocs/faq.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- faq.xml 31 Jan 2003 06:56:49 -0000 1.12 +++ faq.xml 31 Jan 2003 17:42:44 -0000 1.13 @@ -4,6 +4,7 @@ Thomas Mahler Tim O'Brien + Armin Waibel ObJectRelationalBridge FAQ @@ -16,9 +17,9 @@
  • How is OJB related to ODMG and JDO?
  • What are the OJB design principals?
  • Where can I learn more about Object/Relational mapping in general?
  • - + - +

    Getting started

    - + +

    OJB APIs

    - -

    Howto

    + +

    Howto

    @@ -222,7 +237,7 @@

    - OJB has a "pattern driven" design. + OJB has a "pattern driven" design. Please refer to this document for more details

    @@ -236,12 +251,12 @@

    The first thing to ask is: - How are these primitive typed elements (Strings are also treated as primitive types here) + How are these primitive typed elements (Strings are also treated as primitive types here) stored in the database.
    1) are they treated as ordinary domain objects and stored in a separate table?
    2) are they serialized into a Varchar field?
    3) are they stored as a comma separated varchar field?
    - 4) is each element of the vector or array stored in a separate column? + 4) is each element of the vector or array stored in a separate column? (this solution does only work for a fixed number of elements!)

    Follow these steps for solution 3):
    @@ -266,6 +281,42 @@

    + + +

    + We don't know, that depends from the environment OJB runs (hardware, database, driver, application server, ...). + But there are some settings which affect the performance: +

      +
    • The API you use, e.g. PB-api is much faster then the ODMG-api. See which API for more information
    • +
    • PersistenceBroker pool size. See OJB.properties for more information.
    • +
    • Used sequence manager implementation. See sequence manager for more information.
    • +
    • ConnectionFactory implementation / Connection pooling. See connection pooling for more information.
    • +
    • Use of batch mode (when supported by the DB). See repository.dtd for more information.
    • +
    +

    +

    + To test the different settings OJB was shipped with a small performance + test suite, call + bin\build.bat xxx or + bin/build.sh xxx with xxx: +

      +
    • performance +
      + This test compare the OJB api's with direct JDBC calls. To change the programm + parameters see build.xml target performance. +
    • +
    • performance2 +
      + This test checks the multi-threaded performance of OJB. To change the programm + parameters see build.xml target performance2. It's also + possible to run this test standalone, see javadocs org.apache.ojb.broker.Performance2 +
    • +
    + See for further information performance section. +

    +
    + +

    Sorting can be configured by @@ -501,6 +552,7 @@ +

    OJB ships with out of the box support for P6Spy. @@ -645,6 +697,217 @@ Making it work with OJB-JDO will be easy!

    + + +

    + OJB can handle such recursive associations without problems. +

      +
    • + add a collection attribute 'myClasses' to the class myClass + this collection will hold the associated myClass objects. +
    • +
    • + you have to decide wether this assosciation is 1:n or m:n. +
      + for 1:n you just need an additional foreignkey attribute in the MY_CLASS + table. Of course you'll also need a matching attribute in the class myClass. +
      + For a m:n association you'll have to define a intermediary table to hold the + mapping entries. +
    • +
    • + define a collection-descriptor tag in the class-descriptor + of myClass in repository.xml. + Follow the steps in tutorial3.html on 1:n and m:n. +
    • +
    +

    +
    + + + +

    + There are two ways to do that. Define for each user a jdbc-connection-descriptor + (unattractive way, because we have to add each new user to repository file), + or let OJB handle this for you. +
    + For it define one jdbc-connection-descriptor, + now you can use the same jcdAlias name with different User/Password. OJB + copy the defined jdbc-connection-descriptor and replace the username + and password with the given User/Password. Keep in mind, when the + connection-pool element enables connection pooling, every user get its separate pool. + See How does OJB handle connection pooling. +

    +
    + + + +

    + Define for each database a jdbc-connection-descriptor, use the + different jcdAlias names to match the according database. +

    +
    + + + +

    + OJB does connection pooling per default, expect for datasources. Datasources never will be pooled. +
    + Responsible for managing the connections in OJB are implementations of the + org.apache.ojb.broker.accesslayer.ConnectionFactory.java + interface. There are several implementations shipped with OJB called + org.apache.ojb.broker.accesslayer.ConnectionFactoryXXXImpl.java. + You can find among other things a none pooling implementation and a implementation + using jakarta-DBCP api. +
    + To manage the connection pooling define in your jdbc-connection-descriptor a + connection-pool element. Here you can specify which ConnectionFactory implementation + should be used. More info see repository section + or repository.dtd. +

    +
    + + + +

    + The PB-api enabled the possibility to obtain a connection from the current + used PersistenceBroker instance: + +PersistenceBroker broker = PersistenceBrokerFactory. + createPersistenceBroker(myKey); +broker.beginTransaction(); +// do something + +Connection con = broker.serviceConnectionManager().getConnection(); +// perform your connction action and do more + +broker.commitTransaction(); +broker.close(); + + Do not close or commit the connection, this will be done by OJB. + See ditto perform sql queries. +

    +
    + + + +

    + There are serveral ways in OJB to do that. +
    + If you completely want to bypass the OJB + query-api see direct connection use. +
    + A more elegant way is to use a QueryBySQL object: + +String sql = + "SELECT A.Artikel_Nr FROM Artikel A, Kategorien PG" + + " WHERE A.Kategorie_Nr = PG.Kategorie_Nr" + + " AND PG.Kategorie_Nr = 2"; +// get the QueryBySQL +Query q2 = QueryFactory.newQuery(Article.class, sql); + +Iterator iter2 = broker.getIteratorByQuery(q2); +// or +Collection col2 = broker.getCollectionByQuery(q2); + +

    +
    + + + +

    + It is possible to start OJB with an 'empty' repository.xml file: + + + + + + + ]]> + Now you have to declare the jdbc-connection-descriptor and + class-descriptor at runtime. See Connect to database at + runtime and Add a new persistent object (class-descriptor) at runtime + for more information. +

    +
    + + + + +

    + You could add jdbc-connection-descriptors at runtime, using + the MetadataManager: + +ConnectionRepository cr = MetadataManager. + getInstance().connectionRepository(); + +JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor(); +jcd.setJcdAlias("testConnection") +jcd.setUserName("sa"); +jcd.setPassword("sa"); +jcd.setDbAlias("aAlias"); +jcd.setDbms("aDatabase"); +// .... the other required setter + +// add new descriptor +cr.addDescriptor(jcd); + +// Now it's possible to obtain a PB-instance +PBKey key = new PBKey("testConnection", "sa", "sa"); +PersistenceBroker broker = PersistenceBrokerFactory. + createPersistenceBroker(key); + +

    +
    + + + +

    + You could add class-descriptors at runtime, using + the MetadataManager: + +DescriptorRepository dr = MetadataManager. + getInstance().getRepository(); + +ClassDescriptor cld = new ClassDescriptor(dr); +cld.setClassOfObject(A.class); +//.... other setter + +// add the fields of the class +FieldDescriptor fd = new FieldDescriptor(cld, 1); +fd.setPersistentField(A.class, "someAField"); +cld.addFieldDescriptor(fd); + +// now we add the the class descriptor +dr.setClassDescriptor(cld); + +

    +
    + + + +

    + TODO +

    +
    + + +

    + TODO +

    +
    + + +

    + Yes, see deployment instructions in the docs. + Additional you can find some EJB example beans in package org.apache.ojb.ejb + under [jakarta-ojb]/src/ejb. +

    +
    + + + 1.5 +4 -2 jakarta-ojb/xdocs/performance.xml Index: performance.xml =================================================================== RCS file: /home/cvs/jakarta-ojb/xdocs/performance.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- performance.xml 12 Sep 2002 20:41:39 -0000 1.4 +++ performance.xml 31 Jan 2003 17:42:44 -0000 1.5 @@ -61,7 +61,8 @@ the Hypersonic SQL shipped with OJB. A typical output looks like follows:

    performance:
      -      [ojb] [BOOT] INFO: OJB.properties: file:/home/tom/ojb-1-0/build/test/ojb/OJB.properties
      +      [ojb] [BOOT] INFO: OJB.properties:
      +      file:/home/tom/ojb-1-0/build/test/ojb/OJB.properties
             [ojb] .[performance] INFO:
             [ojb] [performance] INFO: inserting 10000 Objects: 6374 msec
             [ojb] [performance] INFO: updating 10000 Objects: 6083 msec
      @@ -88,7 +89,8 @@
             [ojb]
             [ojb] OK (1 tests)
             [ojb]
      -     [jdbc] [BOOT] INFO: OJB.properties: file:/home/tom/ojb-1-0/build/test/ojb/OJB.properties
      +     [jdbc] [BOOT] INFO: OJB.properties:
      +     file:/home/tom/ojb-1-0/build/test/ojb/OJB.properties
            [jdbc] .[performance] INFO:
            [jdbc] [performance] INFO: inserting 10000 Objects: 2494 msec
            [jdbc] [performance] INFO: updating 10000 Objects: 3229 msec