You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2006/02/15 20:22:22 UTC
svn commit: r378068 -
/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml
Author: brj
Date: Wed Feb 15 11:22:20 2006
New Revision: 378068
URL: http://svn.apache.org/viewcvs?rev=378068&view=rev
Log:
Relationships based on non primarykey fields.
backport from ojb 1.x.
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml?rev=378068&r1=378067&r2=378068&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml Wed Feb 15 11:22:20 2006
@@ -111,6 +111,14 @@
column="Kategorie_Nr"
jdbc-type="INTEGER"
/>]]></source>
+ OJB assumes that field used in field-ref references the <em>primary-key</em> field
+ of the referenced type "org.apache.ojb.broker.ProductGroup".
+ If field-ref should point to another field use the <em>target-field-ref</em>:
+ <source><![CDATA[
+ <foreignkey field-ref="productGroupName" target-field-ref="groupName
+ "/>]]></source>
+ An example of a 1:1 relationship using a non-primary-key field can be
+ found <a href="#non-pk-one-to-one">here</a>.
</li>
</ul>
<p>
@@ -210,6 +218,61 @@
<a href="site:faq/primitive-null">how OJB manage <code>null</code> for primitive PK/FK</a>
</note>
+ <anchor id="non-pk-one-to-one"/>
+ <section>
+ <title>1:1 using non-primary-key field</title>
+ <p>
+ This example shows a relationship based on the field "productGroupName" referencing a non-primary-key-field.
+ This field of the class "org.apache.ojb.broker.NoPkReferenceTest$Article_2" is pointing to the
+ field "groupName" of the referenced class.
+ </p>
+ <source><![CDATA[
+<class-descriptor
+ class="org.apache.ojb.broker.NoPkReferenceTest$Article_2"
+ table="Artikel_2" >
+ <field-descriptor
+ name="articleId"
+ column="Artikel_Nr"
+ jdbc-type="INTEGER"
+ primarykey="true"
+ autoincrement="true"
+ />
+ ...
+ <field-descriptor
+ name="productGroupName"
+ column="KatName"
+ jdbc-type="VARCHAR"
+ />
+ ...
+ <reference-descriptor
+ name="productGroup"
+ class-ref="org.apache.ojb.broker.NoPkReferenceTest$ProductGroup_2"
+ >
+ <foreignkey field-ref="productGroupName" target-field-ref="groupName"/>
+ </reference-descriptor>
+</class-descriptor>
+
+<class-descriptor
+ class="org.apache.ojb.broker.NoPkReferenceTest$ProductGroup_2"
+ table="Kategorien_2" >
+ <field-descriptor
+ name="groupId"
+ column="Kategorie_Nr"
+ jdbc-type="INTEGER"
+ primarykey="true"
+ autoincrement="true"
+ />
+ <field-descriptor
+ name="groupName"
+ column="Kategorie_Name"
+ jdbc-type="VARCHAR"
+ />
+ ...
+</class-descriptor>]]></source>
+
+ </section>
+
+
<section>
<title>1:1 auto-xxx setting</title>
<p>
@@ -867,7 +930,7 @@
<a href="site:faq/primitive-null">how OJB manage <code>null</code> for primitive PK/FK</a>
</note>
-
+
<section>
<title>m:n auto-xxx setting</title>
<p>
@@ -1434,22 +1497,22 @@
the Article class) must implement an interface (for example
InterfaceArticle) to be able to benefit from dynamic proxies.
</p>
- <note>
+ <note>
As of OJB 1.0.4, a facility is now present to allow the generation of
dynamic proxies that <strong>do not</strong> require the persistent class
- to implement an interface. Previous versions generated Proxies using the JDK
- proxy pattern. That has been extracted into a new configuration setting named
+ to implement an interface. Previous versions generated Proxies using the JDK
+ proxy pattern. That has been extracted into a new configuration setting named
'ProxyFactoryClass'.
<br/><br/>
Two implementations of this ProxyClass have been provided: the previous JDK-based version (default),
- and a new CGLIB-based implementation. Since the CGLIB version does byte-code
- manipulation to generate the proxy, your class is not required to implement any
- interface. All generated Proxies will automatically be sub-classes of your
+ and a new CGLIB-based implementation. Since the CGLIB version does byte-code
+ manipulation to generate the proxy, your class is not required to implement any
+ interface. All generated Proxies will automatically be sub-classes of your
persistent class.
<br/><br/>
- See below in the section "Customizing the proxy mechanism" for how to enable the new
+ See below in the section "Customizing the proxy mechanism" for how to enable the new
CGLIB Proxy generation.
-
+
</note>
</section>
@@ -1590,14 +1653,14 @@
supplying a user-defined implementation.
</p>
<p>
- For dynamic proxies, you can select a ProxyFactory, as well as provide your own indirection handler.
- Two default indirection handler implementations have been provided that coorespond
- to the apporpriate ProxyFactory (IndirectionHandlerJDKImpl and IndirectionHandlerCGLIBImpl).
+ For dynamic proxies, you can select a ProxyFactory, as well as provide your own indirection handler.
+ Two default indirection handler implementations have been provided that coorespond
+ to the apporpriate ProxyFactory (IndirectionHandlerJDKImpl and IndirectionHandlerCGLIBImpl).
</p>
<p>
- <strong>Note:</strong> All indirection handlers must implement the appropriate base indirection handler
- class, depending on what ProxyFactory is being used. For example: when using ProxyFactoryJDKImpl, the
- specified indirection handler <strong>must</strong> implement the IndirectionHandlerJDK interface.
+ <strong>Note:</strong> All indirection handlers must implement the appropriate base indirection handler
+ class, depending on what ProxyFactory is being used. For example: when using ProxyFactoryJDKImpl, the
+ specified indirection handler <strong>must</strong> implement the IndirectionHandlerJDK interface.
</p>
<p>
Each of the three collection proxy classes can be replaced by a
@@ -1623,7 +1686,7 @@
# - ProxyFactoryCGLIBImpl: Refernece proxies are generated using bytecode manipulation
# from the CGLIB library. Any class can become a dynamic proxy, and not
# just ones that implement an interface.
- # - ProxyFactoryJDKImpl: OJB 1.0 compatiable Proxy implementation. Proxies in this method
+ # - ProxyFactoryJDKImpl: OJB 1.0 compatiable Proxy implementation. Proxies in this method
# can only be generated from classes that implement an interface, and
# the generated Proxy will implement all methods of that interface.
#
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org