arminw 2005/03/28 03:33:37
Modified: src/doc/forrest/src/documentation/content/xdocs/docu/guides
Tag: OJB_1_0_RELEASE odmg-guide.xml
src/doc/forrest/src/documentation/content/xdocs/docu/tutorials
Tag: OJB_1_0_RELEASE odmg-tutorial.xml
src/doc/forrest/src/documentation/content/xdocs Tag:
OJB_1_0_RELEASE site.xml
Log:
fix download link
fix example bug in odmg-tutorial
minor changes in odmg-guide
Revision Changes Path
No revision
No revision
1.1.2.2 +26 -3
db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/Attic/odmg-guide.xml
Index: odmg-guide.xml
===================================================================
RCS file:
/home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/Attic/odmg-guide.xml,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- odmg-guide.xml 24 Mar 2005 17:54:17 -0000 1.1.2.1
+++ odmg-guide.xml 28 Mar 2005 11:33:37 -0000 1.1.2.2
@@ -129,18 +129,41 @@
database.open("jcdAliasName#user#password",
Database.OPEN_READ_WRITE);]]></source>
<p>
The <em>user</em> and <em>password</em> separated by
<em>#</em> hash only needed, when
- the user/passwd not specified in the connection metadata
(jdbc-connection-descriptor).
+ the user/passwd is not specified in the connection metadata
(jdbc-connection-descriptor).
+ </p>
+ <p>
+ The <link
href="site:repository/jdbc-connection-descriptor">jdbc-connection-descriptor</link>
+ may look like:
+ </p>
+ <source><![CDATA[
+<jdbc-connection-descriptor
+ jcd-alias="jcdAliasName"
+ ...
+ username="user"
+ password="password"
+ ...
+ >
+ ...
+</jdbc-connection-descriptor>]]></source>
+ <p>
+ With method call <code>OJB.getInstance()</code> always a
<strong>new</strong>
+ <link
href="ext:odmg-implementation">org.odmg.Implementation</link> instance will be
created and
+ <code>odmg.newDatabase()</code> returns a new
<code>Database</code> instance.
</p>
<p>
For best performance it's recommended to share the
<link
href="ext:odmg-implementation"><code>Implementation</code></link> instance
across
- the application. To get the open database from it use method
<code>Implementation.getDatabase</code>
+ the application. To get the current open database from the
<code>Implementation</code> instance,
+ use method <code>Implementation.getDatabase(null)</code>
</p>
<source><![CDATA[
Implementation odmg = ....
// get current used database
Database database = odmg.getDatabase(null);]]></source>
<p>
+ Or share the open <code>Database</code> instance as well.
+ </p>
+ <p>
See further in FAQ
<link href="site:faq/password-needed">"Needed to put
user/password of database connection in repository file?"</link>.
</p>
No revision
No revision
1.1.2.5 +65 -51
db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/tutorials/odmg-tutorial.xml
Index: odmg-tutorial.xml
===================================================================
RCS file:
/home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/tutorials/odmg-tutorial.xml,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- odmg-tutorial.xml 24 Mar 2005 17:54:17 -0000 1.1.2.4
+++ odmg-tutorial.xml 28 Mar 2005 11:33:37 -0000 1.1.2.5
@@ -65,8 +65,10 @@
<link href="site:mapping-tutorial">mapping tutorial</link>
</p>
<p>
- When using 1:1, 1:n and m:n references the ODMG-api need
specific metadata
- settings on relationship definition - more info see
+ When using 1:1, 1:n and m:n references (the example doesn't
use it) the ODMG-api
+ need specific metadata settings on relationship definition,
the mandatory settings
+ are listed in the
+ <link href="site:odmg-guide/metadata">ODMG-Guide</link> -
additional info see
<link href="site:basic-technique/cascading">auto-xxx
settings</link> and
<link href="site:repository">repository file settings</link>.
</p>
@@ -101,23 +103,34 @@
db.close();]]></source>
<p>
- This opens an ODMG
+ With method call <code>OJB.getInstance()</code> always a
<strong>new</strong>
+ <link
href="ext:odmg-implementation">org.odmg.Implementation</link> instance will be
created and
+ <code>odmg.newDatabase()</code> returns a new
<code>Database</code> instance.
+ </p>
+ <p>
+ Call <code>db.open(...)</code> opens an ODMG
<code>Database</code> using the name specified in
- metadata for the database -- "default" in this case. Notice
the
- <code>Database</code>
- is opened in read/write mode. It is possible to open it in
read-only or write-only
+ <link href="site:odmg-guide/lookup-odmg">metadata for the
database</link> -- "default" in
+ this case. Notice the <code>Database</code> is opened in
read/write mode. It is possible to open it in <em>read-only</em> or
<em>write-only</em>
modes as well.
</p>
<p>
- Once a
+ Once a <code>Implementation</code> instance is created and a
<code>Database</code> has been opened it is available for
use. Unlike
- <code>PersistenceBroker</code> instances, ODMG
- <code>Database</code> instances
+ <link href="site:pb-guide"><code>PersistenceBroker</code>
instances</link>, ODMG
+ <code>Implementation</code> and <code>Database</code>
instances
are threadsafe and can typically be used for the entire
lifecycle of an application.
There is no need to call the
<code>Database.close()</code> method until the database
is truly no longer needed.
</p>
+ <p>
+ The
+ <code>OJB.getInstance()</code> function provides the ODMG
+ <code>Implementation</code>
+ instance required for using the ODMG API. From here on out
it is straight ODMG
+ code that should work against any compliant ODMG
implementation.
+ </p>
</section>
@@ -128,22 +141,19 @@
store within the context of a transaction:
</p>
<source><![CDATA[
-public static void storeProduct(Product product)
+public static void storeNewProduct(Product product)
{
-Implementation impl = OJB.getInstance();
-Transaction tx = impl.newTransaction();
-tx.begin();
-tx.lock(product, Transaction.WRITE);
-tx.commit();
+ // get the used Implementation instance
+ Implementation odmg = ...;
+ Transaction tx = odmg.newTransaction();
+ tx.begin();
+ // get current used Database instance
+ Database db = odmg.getDatabase(null);
+ // make persistent new object
+ db.makePersistent(product);
+ tx.commit();
}]]></source>
<p>
- The
- <code>OJB.getInstance()</code> function provides the ODMG
- <code>Implementation</code>
- instance required for using the ODMG API. From here on out
it is straight ODMG
- code that should work against any compliant ODMG
implementation.
- </p>
- <p>
Once the ODMG implementation has been obtained it is used to
begin a transaction,
obtain a write lock on the
<code>Product</code>, and commit the transaction. It is
@@ -166,20 +176,21 @@
<source><![CDATA[
public static Product findProductByName(String name) throws Exception
{
-Implementation impl = OJB.getInstance();
-Transaction tx = impl.newTransaction();
-tx.begin();
-
-OQLQuery query = impl.newOQLQuery();
-query.create("select products from "
- + Product.class.getName()
- + " where name = $1");
-query.bind(name);
-DList results = (DList) query.execute();
-Product product = (Product) results.iterator().next();
+ // get the used Implementation instance
+ Implementation odmg = ...;
+ Transaction tx = odmg.newTransaction();
+ tx.begin();
+
+ OQLQuery query = odmg.newOQLQuery();
+ query.create("select products from "
+ + Product.class.getName()
+ + " where name = $1");
+ query.bind(name);
+ List results = (List) query.execute();
+ Product product = (Product) results.iterator().next();
-tx.commit();
-return product;
+ tx.commit();
+ return product;
}]]></source>
</section>
@@ -193,18 +204,19 @@
<source><![CDATA[
public static void sellProduct(Product product, int number)
{
-Implementation impl = OJB.getInstance();
-Transaction tx = impl.newTransaction();
-tx.begin();
+ // get the used Implementation instance
+ Implementation odmg = ...;
+ Transaction tx = odmg.newTransaction();
+ tx.begin();
-tx.lock(product, Transaction.WRITE);
-product.setStock(new Integer(product.getStock().intValue() - number));
+ tx.lock(product, Transaction.WRITE);
+ product.setStock(new Integer(product.getStock().intValue() - number));
-tx.commit();
+ tx.commit();
}]]></source>
<p>
- The sample code obtains a write lock on the object, binding
it to the transaction,
- changes the object, and commits the transaction. The newly
modified
+ The sample code obtains a write lock on the object
(<strong>before</strong> the changes are made),
+ binding it to the transaction, changes the object, and
commits the transaction. The newly modified
<code>Product</code>
now has a new
<code>stock</code> value.
@@ -225,13 +237,15 @@
<source><![CDATA[
public static void deleteProduct(Product product)
{
-Implementation impl = OJB.getInstance();
-Transaction tx = impl.newTransaction();
-
-tx.begin();
-Database db = impl.getDatabase(product);
-db.deletePersistent(product);
-tx.commit();
+ // get the used Implementation instance
+ Implementation odmg = ...;
+ Transaction tx = odmg.newTransaction();
+
+ tx.begin();
+ // get current used Database instance
+ Database db = odmg.getDatabase(null);
+ db.deletePersistent(product);
+ tx.commit();
}
]]></source>
<p>
No revision
No revision
1.3.2.11 +4 -3
db-ojb/src/doc/forrest/src/documentation/content/xdocs/site.xml
Index: site.xml
===================================================================
RCS file:
/home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/site.xml,v
retrieving revision 1.3.2.10
retrieving revision 1.3.2.11
diff -u -r1.3.2.10 -r1.3.2.11
--- site.xml 24 Mar 2005 17:54:17 -0000 1.3.2.10
+++ site.xml 28 Mar 2005 11:33:37 -0000 1.3.2.11
@@ -100,6 +100,7 @@
<odmg-guide label="ODMG-api guide" href="odmg-guide.html">
<no-oql href="#no-oql"/>
<lookup-odmg href="#lookup-odmg"/>
+ <metadata href="#metadata"/>
</odmg-guide>
<platform label="Platform settings" href="platforms.html"
description=""/>
<ojb-properties label="OJB.properties File"
href="ojb-properties.html" description=""/>
@@ -245,8 +246,8 @@
<ojb>
<wiki-page href="http://wiki.apache.org/db-ojb"/>
<bugtracker
href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10700"/>
- <binaries-version
href="http://www.apache.org/dyn/closer.cgi/db/ojb/db-ojb-1.0.1/"/>
- <source-version
href="http://www.apache.org/dyn/closer.cgi/db/ojb/db-ojb-1.0.1/"/>
+ <binaries-version
href="http://www.apache.org/dyn/closer.cgi/db/ojb/"/>
+ <source-version
href="http://www.apache.org/dyn/closer.cgi/db/ojb/"/>
<cvs-view href="http://cvs.apache.org/viewcvs/db-ojb/"/>
<cvs-index href="http://jakarta.apache.org/site/cvsindex.html"/>
<license-site href="http://www.apache.org/LICENSE"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]