cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb samples.jdo
Date Fri, 10 Oct 2003 06:10:01 GMT
antonio     2003/10/09 23:10:01

  Modified:    src/blocks/ojb/samples/woody employee.js employee.xml
               src/blocks/ojb/WEB-INF/classes repository.dtd repository.xml
                        OJB.properties
               lib      jars.xml
               src/blocks/ojb/java/org/apache/cocoon/ojb/samples
                        EmployeeImpl.java
               src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb
                        samples.jdo
  Added:       src/blocks/ojb/lib db-ojb-1.0.rc4-20031009.jar
  Removed:     src/blocks/ojb/lib db-ojb-1.0.rc4-20031008.jar
  Log:
  OJB woody binding example is working!
  
  Revision  Changes    Path
  1.4       +11 -4     cocoon-2.1/src/blocks/ojb/samples/woody/employee.js
  
  Index: employee.js
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/samples/woody/employee.js,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- employee.js	9 Oct 2003 18:30:53 -0000	1.3
  +++ employee.js	10 Oct 2003 06:10:00 -0000	1.4
  @@ -1,14 +1,18 @@
   cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
   
   function employeeform_jdo(form) {
  -    // Create a empty Bean
   
  +	// Get OJB factory
      	var factory = cocoon.getComponent(Packages.org.apache.cocoon.ojb.jdo.components.JdoPMF.ROLE);
  +
  +    // Create a empty Bean
       var bean = new Packages.org.apache.cocoon.ojb.samples.Employee();
       var ojbEmployee = Packages.org.apache.cocoon.ojb.samples.EmployeeImpl();
  +
   	// Fill some initial data to the bean
  +	bean.setId(1);
       // Load bean based on the given PrimaryKey
  -    bean = ojbEmployee.load(1, factory);
  +    ojbEmployee.retrieve(bean, factory);
   
       // Load the Bean to the form
       form.load(bean);
  @@ -17,9 +21,12 @@
       // Update the Bean based on user input
   	form.save(bean);
   
  -    // Save Bean in Database
  -	ojbEmployee.save(bean, factory);
  +    // Insert Bean in Database
  +	ojbEmployee.insert(bean, factory);
  +	// Clean up the operation
   	cocoon.releaseComponent(factory);
  +
  +    // Send response to the user
       cocoon.request.setAttribute("employeeform", form.getWidget());
       cocoon.sendPage("jdo/woody/employee-form-success");
   }
  
  
  
  1.3       +3 -3      cocoon-2.1/src/blocks/ojb/samples/woody/employee.xml
  
  Index: employee.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/samples/woody/employee.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- employee.xml	8 Oct 2003 16:42:44 -0000	1.2
  +++ employee.xml	10 Oct 2003 06:10:00 -0000	1.3
  @@ -63,7 +63,7 @@
           <wd:label>ID :</wd:label>
           <wd:datatype base="integer">
           <wd:validation>
  -                <wd:range min="5"/>
  +                <wd:range min="20"/>
               </wd:validation>
           </wd:datatype>
       </wd:field>
  
  
  
  1.2       +181 -17   cocoon-2.1/src/blocks/ojb/WEB-INF/classes/repository.dtd
  
  Index: repository.dtd
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/WEB-INF/classes/repository.dtd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- repository.dtd	28 Sep 2003 04:31:11 -0000	1.1
  +++ repository.dtd	10 Oct 2003 06:10:00 -0000	1.2
  @@ -2,6 +2,7 @@
   	ObJectRelationalBridge - Bridging Java objects and relational dabatases
   	This DTD describes the grammar of the Descriptor repository
   	Author: Thomas Mahler, (c) 2000, 2001, 2002, 2003
  +    @version $Id$
     -->
   
   <!--
  @@ -42,8 +43,6 @@
   -->
   <!ELEMENT documentation (#PCDATA)>
   
  -<!ELEMENT database-repository (jdbc-connection-descriptor*)>
  -
   <!--
   	The attribute element allows to add custom attributes.
   
  @@ -57,8 +56,7 @@
       define which sequence manager implementation should be used within
       the defined connection.
     -->
  -<!ELEMENT jdbc-connection-descriptor (documentation?, attribute*, connection-pool?,
sequence-manager?)>
  -
  +<!ELEMENT jdbc-connection-descriptor (documentation?, attribute*, object-cache?, connection-pool?,
sequence-manager?)>
   
   <!--
       The jcdAlias attribute is a shortcut name for the defined connection
  @@ -118,8 +116,9 @@
   	jcd-alias CDATA #REQUIRED
       default-connection (true | false) "false"
       platform (Db2 | Hsqldb | Informix | MsAccess | MsSQLServer |
  -	          MySQL | Oracle | PostgreSQL | Sybase | SybaseASE|
  -              SybaseASA | Sapdb | Firebird | Axion | NonstopSql ) "Hsqldb"
  +	          MySQL | Oracle | PostgreSQL | Sybase | SybaseASE |
  +              SybaseASA | Sapdb | Firebird | Axion | NonstopSql |
  +              Oracle9i ) "Hsqldb"
   	jdbc-level (1.0 | 2.0 | 3.0) "1.0"
   	eager-release (true | false) "false"
       batch-mode (true | false) "false"
  @@ -139,6 +138,36 @@
   
   
   <!--
  +    The object-cache element can be used to specify the ObjectCache
  +    implementation used by OJB. There are three levels for
  +    declaration:
  +        1. in OJB.properties file, to declare the standard (default)
  +        ObjectCache implementation.
  +        2. on jdbc-connection-descriptor level, to declare ObjectCache implementation
  +        on a per connection/user level
  +        3. on class-descriptor level, to declare ObjectCache implementation
  +        on a per class level
  +
  +    The priority of the declared object-cache elements are:
  +    per class > per jdbc descriptor > standard
  +
  +    E.g. if you declare ObjectCache 'cacheDef' as standard, set
  +    ObjectCache 'cacheA' in class-descriptor for class A and class B
  +    does not declare an object-cache element. Then OJB use cacheA as ObjectCache
  +    for class A and cacheDef for class B
  +-->
  +<!ELEMENT object-cache (documentation?, attribute*)>
  +
  +<!--
  +    Attribute 'class' specifies the full qualified class name of
  +    the used ObjectCache implementation.
  +-->
  +<!ATTLIST object-cache
  +    class                          CDATA #REQUIRED
  +>
  +
  +
  +<!--
   	The connection-pool element specifies the connection pooling
   	parameter.
   -->
  @@ -278,12 +307,20 @@
   
   	A class-descriptor may contain user defined custom attribute elements.
   
  +    The insert-procedure, update-procedure and delete-procedure elements
  +    identify the procedure/function that is defined in the database which
  +    will handle the insertion, update or deletion of an instance of this
  +    class.  These elements are all optional.  If they are absent then basic
  +    sql statements (INSERT INTO xxx..., UPDATE xxx, DELETE FROM xxx) will
  +    be utilized.
  +
     -->
   <!ELEMENT class-descriptor
   	((documentation?, extent-class+, attribute*) |
  -	(documentation?, extent-class*, field-descriptor+,
  +	(documentation?, object-cache?, extent-class*, field-descriptor+,
   	 reference-descriptor*, collection-descriptor*,
  -     index-descriptor*, attribute*))>
  +     index-descriptor*, attribute*,
  +     insert-procedure?, update-procedure?, delete-procedure?))>
   
   
   <!--
  @@ -313,15 +350,16 @@
   	propagate to this class.  Currently relevant for the ODMG layer only.
   
   	The optional initialization-method specifies a no-argument instance
  -	method that is invoked after reading an instnace from a database row.
  +	method that is invoked after reading an instance from a database row.
   	It can be used to do initialization and validations.
   
  -	The optional factory-method specifies a static no-argument method
  -	(specified by the factory-class attribute)
  +	The optional factory-class specifies a factory-class that
   	that is to be used instead of a no argument constructor.
  -	If either factory-class or factory-method is specified, the other
  -	is mandatory.
  -	
  +	If the factory-class is specified the factory-method
  +	also must be defined.
  +	factory-method refers to a static no-argument method
  +	of the factory-class class.
  +
   	The refresh attribute can be set to true to force OJB to refresh
   	instances when loaded from cache. It's set to false by default.
   
  @@ -386,7 +424,9 @@
   	The column attribute specifies the column the persistent classes field
   	is mapped to.
   
  -	The jdbc-type attribute specifies the JDBC type of the column.
  +	The optional jdbc-type attribute specifies the JDBC type of the column.
  +	If not specified OJB tries to identify the JDBC type by inspecting the
  +	Java attribute by reflection.
   
   	The primarykey specifies if the column is a primary key column.
   
  @@ -448,7 +488,7 @@
   	jdbc-type (BIT | TINYINT | SMALLINT | INTEGER | BIGINT | DOUBLE |
   	           FLOAT | REAL | NUMERIC | DECIMAL | CHAR | VARCHAR |
   	           LONGVARCHAR | DATE | TIME | TIMESTAMP | BINARY |
  -	           VARBINARY | LONGVARBINARY | CLOB | BLOB) #REQUIRED
  +	           VARBINARY | LONGVARBINARY | CLOB | BLOB | BOOLEAN) #IMPLIED
   	primarykey (true | false) "false"
   	nullable (true | false) "true"
   	indexed (true | false) "false"
  @@ -634,7 +674,7 @@
       were set to true, but the auto-update and auto-delete attributes themself
       must be always set to false for use with OTM layer.
   
  -	
  +
     -->
   <!ATTLIST collection-descriptor
   	name CDATA #IMPLIED
  @@ -729,3 +769,127 @@
   <!ELEMENT index-column (documentation?)>
   <!ATTLIST index-column
       name CDATA #REQUIRED>
  +
  +<!--
  +	Identifies the procedure/function that should be used to handle
  +    insertions for a specific class-descriptor.
  +
  +    The nested 'argument' elements define the argument list for the
  +    procedure/function as well as the source for each argument.
  +
  +    The name attribute identifies the name of the procedure/function to use
  +
  +    The return-field-ref identifies the field-descriptor that will receive
  +    the value that is returned by the procedure/function.  If the procedure/
  +    function does not include a return value, then do not specify a value
  +    for this attribute.
  +
  +    The include-all-fields attribute indicates if all field-descriptors in
  +    the corresponding class-descriptor are to be passed to the procedure/
  +    function.  If include-all-fields is 'true', any nested 'argument'
  +    elements will be ignored.  In this case, values for all field-descriptors
  +    will be passed to the procedure/function.  The order of values that are
  +    passed to the procedure/function will match the order of field-descriptors
  +    on the corresponding class-descriptor.  If include-all-fields is false,
  +    then values will be passed to the procedure/function based on the
  +    information in the nested 'argument' elements.
  +  -->
  +<!ELEMENT insert-procedure
  +	(documentation?, (runtime-argument | constant-argument)?, attribute*)>
  +<!ATTLIST insert-procedure
  +	name CDATA #REQUIRED
  +    return-field-ref CDATA #IMPLIED
  +    include-all-fields (true | false) "false"
  +>
  +
  +<!--
  +	Identifies the procedure/function that should be used to handle
  +    updates for a specific class-descriptor.
  +
  +    The nested 'argument' elements define the argument list for the
  +    procedure/function as well as the source for each argument.
  +
  +    The name attribute identifies the name of the procedure/function to use
  +
  +    The return-field-ref identifies the field-descriptor that will receive
  +    the value that is returned by the procedure/function.  If the procedure/
  +    function does not include a return value, then do not specify a value
  +    for this attribute.
  +
  +    The include-all-fields attribute indicates if all field-descriptors in
  +    the corresponding class-descriptor are to be passed to the procedure/
  +    function.  If include-all-fields is 'true', any nested 'argument'
  +    elements will be ignored.  In this case, values for all field-descriptors
  +    will be passed to the procedure/function.  The order of values that are
  +    passed to the procedure/function will match the order of field-descriptors
  +    on the corresponding class-descriptor.  If include-all-fields is false,
  +    then values will be passed to the procedure/function based on the
  +    information in the nested 'argument' elements.
  +  -->
  +<!ELEMENT update-procedure
  +	(documentation?, (runtime-argument | constant-argument)?, attribute*)>
  +<!ATTLIST update-procedure
  +	name CDATA #REQUIRED
  +    return-field-ref CDATA #IMPLIED
  +    include-all-fields (true | false) "false"
  +>
  +
  +<!--
  +	Identifies the procedure/function that should be used to handle
  +    deletions for a specific class-descriptor.
  +
  +    The nested 'runtime-argument' and 'constant-argument' elements define
  +    the argument list for the procedure/function as well as the source
  +    for each argument.
  +
  +    The name attribute identifies the name of the procedure/function to use
  +
  +    The return-field-ref identifies the field-descriptor that will receive
  +    the value that is returned by the procedure/function.  If the procedure/
  +    function does not include a return value, then do not specify a value
  +    for this attribute.
  +
  +    The include-pk-only attribute indicates if all field-descriptors in
  +    the corresponding class-descriptor that are identified as being part of
  +    the primary key are to be passed to the procedure/function.  If
  +    include-pk-only is 'true', any nested 'argument' elements will be
  +    ignored.  In this case, values for all field-descriptors that are identified
  +    as being part of the primary key will be passed to the procedure/function.
  +    The order of values that are passed to the procedure/function will match
  +    the order of field-descriptors on the corresponding class-descriptor.
  +    If include-pk-only is false, then values will be passed to the procedure/
  +    function based on the information in the nested 'argument' elements.
  +  -->
  +<!ELEMENT delete-procedure
  +	(documentation?, (runtime-argument | constant-argument)?, attribute*)>
  +<!ATTLIST delete-procedure
  +	name CDATA #REQUIRED
  +    return-field-ref CDATA #IMPLIED
  +    include-pk-only (true | false) "false"
  +>
  +<!--
  +    Defines an argument that is passed to a procedure/function.  Each argument
  +    will be set to a value from a field-descriptor or null.
  +
  +    The field-ref attribute identifies the field-descriptor in the corresponding
  +    class-descriptor that provides the value for this argument.  If this attribute
  +    is unspecified, then this argument will be set to null.
  +-->
  +<!ELEMENT runtime-argument
  +	(documentation?, attribute*)>
  +<!ATTLIST runtime-argument
  +	field-ref CDATA #IMPLIED
  +    return (true | false) "false"
  +>
  +<!--
  +    Defines a constant value that is passed to a procedure/function.
  +
  +    The value attribute identifies the value that is passed to the procedure/
  +    function.
  +-->
  +<!ELEMENT constant-argument
  +	(documentation?, attribute*)>
  +<!ATTLIST constant-argument
  +    value CDATA #REQUIRED
  +>
  +
  
  
  
  1.4       +0 -1      cocoon-2.1/src/blocks/ojb/WEB-INF/classes/repository.xml
  
  Index: repository.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/WEB-INF/classes/repository.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- repository.xml	9 Oct 2003 18:30:53 -0000	1.3
  +++ repository.xml	10 Oct 2003 06:10:00 -0000	1.4
  @@ -27,7 +27,6 @@
           dbalias="hsql://localhost:9002"
           username="sa"
           password=""
  -        eager-release="true"
           batch-mode="false"
           useAutoCommit="1"
           ignoreAutoCommitExceptions="false"
  
  
  
  1.2       +55 -16    cocoon-2.1/src/blocks/ojb/WEB-INF/classes/OJB.properties
  
  Index: OJB.properties
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/WEB-INF/classes/OJB.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OJB.properties	28 Sep 2003 04:31:11 -0000	1.1
  +++ OJB.properties	10 Oct 2003 06:10:00 -0000	1.2
  @@ -2,6 +2,7 @@
   # Version: 1.0
   # (c) 2001, 2002, 2003 Apache Software Foundation
   # Author: Thomas Mahler and many others
  +# @version $Id$
   #
   #----------------------------------------------------------------------------------------
   # repository file settings
  @@ -37,6 +38,10 @@
   # This is the singlevm implementation:
   PersistenceBrokerClass=org.apache.ojb.broker.core.PersistenceBrokerImpl
   #
  +# This is an implementation that uses Prevayler (prevayler.sf.net) as the persistent storage.
  +# Using this implementation OJB works as a simple OODBMS
  +#PersistenceBrokerClass=org.apache.ojb.broker.prevayler.PBPrevaylerImpl
  +#
   #
   #----------------------------------------------------------------------------------------
   # PersistenceBrokerFactory pool
  @@ -159,13 +164,27 @@
   #----------------------------------------------------------------------------------------
   # Object cache
   #----------------------------------------------------------------------------------------
  -# The ObjectCacheClass entry tells OJB which concrete instance Cache
  -# implementation is to be used.
  +# The ObjectCacheClass entry tells OJB which concrete ObjectCache
  +# implementation is to be used as standard cache.
  +# Its also possible to override this entry adding object-cache elements
  +# on jdbc-connection-descriptor level and
  +# per class-descriptor in repository file. More info see documentation.
  +#
   ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
   #ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl
   #ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
  -#ObjectCacheClass=org.apache.ojb.broker.cache.MetaObjectCacheJCSImpl
  -#ObjectCacheClass=org.apache.ojb.broker.cache.MetaObjectCachePerClassImpl
  +#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheJCSPerClassImpl
  +#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerClassImpl
  +#
  +#
  +# This property is only relevant if the per class-descriptor object-cache
  +# declaration was used in conjunction with metadata runtime changes.
  +# If set 'flase' the class name of the object is used
  +# to find a per class ObjectCache implementation.
  +# If set 'true' the ObjectCacheDescriptor instance is used as key to
  +# find a per class ObjectCache, this enables to use different ObjectCache
  +# instances for the same class.
  +descriptorBasedCaches=false
   #
   #
   # Use CacheFilters to do filter operations before caching methods were
  @@ -251,8 +270,8 @@
   DEFAULT.LogLevel=WARN
   # Logger for PersistenceBrokerImpl class
   org.apache.ojb.broker.core.PersistenceBrokerImpl.LogLevel=WARN
  -# Logger for PersistenceBrokerFactory class
  -org.apache.ojb.broker.PersistenceBrokerFactory.LogLevel=WARN
  +# Logger for PersistenceBrokerFactory class PersistenceBrokerFactoryDefaultImpl
  +org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.LogLevel=WARN
   # Logger for RepositoryXmlHandler, useful for debugging parsing of repository.xml!
   org.apache.ojb.broker.metadata.RepositoryXmlHandler.LogLevel=WARN
   # Logger for JdbcAccess, useful for debugging JDBC related problems
  @@ -265,10 +284,10 @@
   org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=WARN
   # Logger for RepositoryPersistor
   org.apache.ojb.broker.metadata.RepositoryPersistor.LogLevel=WARN
  -# Logger for PersistenceBrokerFactoryDefaultImpl
  -org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.LogLevel=WARN
  -# Logger for ConnectionFactory
  -org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.LogLevel=ERROR
  +# Logger for ConnectionFactory base class
  +org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.LogLevel=WARN
  +# Logger for ConnectionManager
  +org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.LogLevel=WARN
   #
   # Special Logger categories used in test suite and tutorials
   #
  @@ -290,13 +309,13 @@
   # The OqlCollectionClass entry defines the collection type returned
   # from OQL queries. By default this value is set to DListImpl.
   # This will be good for most situations as DList allows maximum flexibility
  -# in a ODMG environment.
  +# in a ODMG environment. See also section 'ODMG settings'.
   # Using DLists for large resultsets may be bad for application performance.
   # For these scenarios you can use ArrayLists or Vectors.
   # Important note: the collections class to be used MUST implement the
   # interface org.apache.ojb.broker.ManageableCollection.
   #
  -OqlCollectionClass=org.apache.ojb.odmg.collections.DListImpl
  +OqlCollectionClass=org.apache.ojb.odmg.collections.DListImpl_2
   # OqlCollectionClass=org.apache.ojb.broker.util.collections.ManageableArrayList
   # OqlCollectionClass=org.apache.ojb.broker.util.ManageableVector
   #
  @@ -306,6 +325,30 @@
   #
   #
   #----------------------------------------------------------------------------------------
  +# ODMG settings
  +#----------------------------------------------------------------------------------------
  +# Used ODMG collection implementation classes
  +# (e.g. when do a Implementation#newDlist() call)
  +#
  +# org.odmg.DList implementation class
  +DListClass=org.apache.ojb.odmg.collections.DListImpl_2
  +#DListClass=org.apache.ojb.odmg.collections.DListImpl
  +#
  +# org.odmg.DArray implementation class
  +DArrayClass=org.apache.ojb.odmg.collections.DListImpl_2
  +#DArrayClass=org.apache.ojb.odmg.collections.DListImpl
  +#
  +# org.odmg.DMap implementation class
  +DMapClass=org.apache.ojb.odmg.collections.DMapImpl
  +#
  +# org.odmg.DBag implementation class
  +DBagClass=org.apache.ojb.odmg.collections.DBagImpl
  +#
  +# org.odmg.DSet implementation class
  +DSetClass=org.apache.ojb.odmg.collections.DSetImpl
  +#
  +#
  +#----------------------------------------------------------------------------------------
   # Meta data / mapping settings
   #----------------------------------------------------------------------------------------
   # The PersistentFieldClass property defines the implementation class
  @@ -335,10 +378,6 @@
   #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImpl
   #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDynaBeanAccessImpl
   #
  -# outdated deprecated versions:
  -#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldMaxPerformanceImpl
  -#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentNestedFieldMaxPerformanceImpl
  -#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldPropertyImpl
   #
   #----------------------------------------------------------------------------------------
   # Component Intercepting for Profiling and Tracing
  
  
  
  1.112     +2 -2      cocoon-2.1/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/lib/jars.xml,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- jars.xml	8 Oct 2003 16:42:44 -0000	1.111
  +++ jars.xml	10 Oct 2003 06:10:00 -0000	1.112
  @@ -892,7 +892,7 @@
   	    for Java Objects against relational databases.
   	</description>
   	<used-by>OJB</used-by>
  -	<lib>ojb/lib/db-ojb-1.0.rc4-20031008.jar</lib>
  +	<lib>ojb/lib/db-ojb-1.0.rc4-20031009.jar</lib>
   	<homepage>http://db.apache.org/ojb/</homepage>
     </file>
     <!-- OJB block end (6-Aug-2003) -->
  
  
  
  1.3       +83 -54    cocoon-2.1/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/EmployeeImpl.java
  
  Index: EmployeeImpl.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/java/org/apache/cocoon/ojb/samples/EmployeeImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EmployeeImpl.java	9 Oct 2003 18:30:53 -0000	1.2
  +++ EmployeeImpl.java	10 Oct 2003 06:10:00 -0000	1.3
  @@ -1,73 +1,95 @@
   /*
  - * Created on 08-oct-2003
  - *
  - * To change the template for this generated file go to
  - * Window>Preferences>Java>Code Generation>Code and Comments
  - */
  -package org.apache.cocoon.ojb.samples;
   
  -import java.util.Collection;
  -import java.util.Iterator;
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  +
  + Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  +
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  +
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  +
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  +
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  +
  + 4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
  +    used to  endorse or promote  products derived from  this software without
  +    prior written permission. For written permission, please contact
  +    apache@apache.org.
  +
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  +
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  +
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
  + Software Foundation, please see <http://www.apache.org/>.
  +
  +*/
  +package org.apache.cocoon.ojb.samples;
   
  -import javax.jdo.Extent;
   import javax.jdo.PersistenceManager;
  -import javax.jdo.Query;
   import javax.jdo.Transaction;
   
   import org.apache.cocoon.ojb.jdo.components.JdoPMF;
  -
  +import org.apache.ojb.broker.Identity;
  +import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.PersistenceBrokerFactory;
   /**
  - * @author agallardo
  + *  Department's Impl
    *
  - * To change the template for this generated type comment go to
  - * Window>Preferences>Java>Code Generation>Code and Comments
  - */
  + * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
  + * @version CVS $Id$
  +*/
   public class EmployeeImpl {
  -	private Employee emp;
  -	
  +
   	public EmployeeImpl(){}
   	
   	
  -	public Employee load(int id, JdoPMF pmf) {
  -		String filter = "employee.id ==" + id;
  +	public void retrieve(Employee bean, JdoPMF pmf) {
  +		
   		/* 1. Get the PersistenceManager */
   		PersistenceManager persistenceManager = pmf.getPersistenceManager();
  -		Extent extent = persistenceManager.getExtent(Employee.class, true);
  -		Query query = persistenceManager.newQuery(extent, filter);
  -		query.setOrdering("employee.id ascending");
  -		Collection result = (Collection)query.execute();
  -		Iterator iter = result.iterator();
  -		while(iter.hasNext()) {
  -			Employee e = (Employee) iter.next();
  -			if (id == e.getId())
  -				return e;
  -		}
  -		return null;
  +		
  +		Employee e = new Employee();
  +		e.setId(bean.getId());
  +		PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +		Identity oid = new Identity(e, broker);
  +		
  +		Employee b = new Employee();
  +		//	2. start transaction
  +		persistenceManager.currentTransaction().begin();
  +		// 3. Get the Object based on the primary key
  +		b = (Employee) persistenceManager.getObjectById(oid, false);
  +		// 4. Copy data to bean
  +		copyData(b, bean);
  +		// 5. End transaction
  +		persistenceManager.currentTransaction().commit();
   	}
   	
  -//	public Employee load(int id, JdoPMF pmf) {
  -//		
  -//		/* 1. Get the PersistenceManager */
  -//		PersistenceManager persistenceManager = pmf.getPersistenceManager();
  -//		
  -//		Employee e = new Employee();
  -//		e.setId(id);
  -//		PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  -//		Identity oid = new Identity(e, broker);
  -//		
  -//		Employee toBeReturned = new Employee();
  -//		//	2. start transaction
  -//		persistenceManager.currentTransaction().begin();
  -//		// 3. Get the Object based on the primary key
  -//		toBeReturned = (Employee) persistenceManager.getObjectById(oid, false);
  -//		// 4. End transaction
  -//		persistenceManager.currentTransaction().commit();
  -//		return toBeReturned;
  -//	}
  -	
  -	public void save(Employee e, JdoPMF pmf) {
  -		// Setting up the Bean 
  -		emp = e;
  +	public void insert(Employee e, JdoPMF pmf) {
   		/* 1. Get the PersistenceManager */
   		PersistenceManager persistenceManager = pmf.getPersistenceManager();
   		// 2. Get current transaction
  @@ -75,8 +97,15 @@
   		// 3. Start a Transaction
   		tx.begin();
   		// 4. now perform persistence operations. Store the Employee
  -		persistenceManager.makePersistent(emp);
  +		persistenceManager.makePersistent(e);
   		// 5. Commit the transaction
   		tx.commit();
  +	}
  +	
  +	private void copyData(Employee from, Employee to)
  +	{
  +		to.setId(from.getId());
  +		to.setDepartmentId(from.getDepartmentId());
  +		to.setName(from.getName());
   	}
   }
  
  
  
  1.1                  cocoon-2.1/src/blocks/ojb/lib/db-ojb-1.0.rc4-20031009.jar
  
  	<<Binary file>>
  
  
  1.2       +8 -8      cocoon-2.1/src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb/samples.jdo
  
  Index: samples.jdo
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/ojb/WEB-INF/classes/org/apache/cocoon/ojb/samples.jdo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- samples.jdo	28 Sep 2003 04:31:11 -0000	1.1
  +++ samples.jdo	10 Oct 2003 06:10:01 -0000	1.2
  @@ -1,24 +1,24 @@
   <?xml version="1.0" encoding="UTF-8"?>
  -<!DOCTYPE jdo SYSTEM "file://build/org/apache/cocoon/ojb/samples/jdo.dtd">
  +<!DOCTYPE jdo SYSTEM "jdo.dtd">
   
   <jdo>
       <package name="org.apache.cocoon.ojb.samples">
  -        <class name="Department">
  -            <extension vendor-name="ojb" key="table" value="DEPARTMENT"/>
  +         <class name="Employee">
  +            <extension vendor-name="ojb" key="table" value="EMPLOYEE"/>
               <field name="id">
                   <extension vendor-name="ojb" key="column" value="ID"/>
               </field>
  +            <field name="departmentId">
  +                <extension vendor-name="ojb" key="column" value="DEPARTMENT_ID"/>
  +            </field>
               <field name="name">
                   <extension vendor-name="ojb" key="column" value="NAME"/>
               </field>
           </class>
  -        <class name="Employee">
  -            <extension vendor-name="ojb" key="table" value="EMPLOYEE"/>
  +        <class name="Department">
  +            <extension vendor-name="ojb" key="table" value="DEPARTMENT"/>
               <field name="id">
                   <extension vendor-name="ojb" key="column" value="ID"/>
  -            </field>
  -            <field name="departmentId">
  -                <extension vendor-name="ojb" key="column" value="DEPARTMENT_ID"/>
               </field>
               <field name="name">
                   <extension vendor-name="ojb" key="column" value="NAME"/>
  
  
  

Mime
View raw message