Return-Path: Getting started OJB APIs Howto Howto
- OJB has a "pattern driven" design.
+ OJB has a "pattern driven" design.
Please refer to this document for more details
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.
+ 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:
+
-
+
+
-
-
java.sql.Connection
within OJB?class-descriptor
) at runtime?
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 @@
+
+
+ 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
+ build.xml
target performance
.
+ performance2
+ build.xml
target performance2
. It's also
+ possible to run this test standalone, see javadocs org.apache.ojb.broker.Performance2
+ 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. +
myClass
+ this collection will hold the associated myClass
objects.
+ myClass
.
+ 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:
+
+ 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:
+
+
+ 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
:
+
+
+ You could add class-descriptors
at runtime, using
+ the MetadataManager
:
+
+
+ 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
.
+