You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Lemke, Wesley" <We...@LibertyMutual.com> on 2004/11/16 21:04:32 UTC

RE: OJB, Optimistic Locking, and multiple threads

> We are currently using OJB, with a single JVM, but we are planning on
> going to a clustered environment.  I was doing some testing of just
> one class with a few fields that maps to one table.  Instead of
> running multiple applications on multiple JVMs, I thought it would be
> easier to have one application spawn several threads, and each of the
> threads persist a different object.  If I run one Thread everything
> works fine, but when I increase the number of threads I get an
> OptimisticLockException.  I followed the clustering how-to to get
> everything set up.  Should this work the same with multiple threads as
> it would with multiple JVMs?  If so can someone let me know what I am
> doing wrong?  
> 
> I'll put the relevant code/mapping below.  Let me know if anything
> else would be helpful to see.
> 
> Thanks,
> Wes
> 
> The servlet class:  
> public class WesServlet extends HttpServlet {
> 	private static final int THREAD_COUNT = 3;
> 	private static ClientAdder[] threads = null;
> 	
> 	protected void doPost(HttpServletRequest req,
> HttpServletResponse resp)
> 		throws ServletException, IOException {
> 			threads = new ClientAdder[THREAD_COUNT];
> 
> 			PrintWriter writer = resp.getWriter();
> 	
> writer.println("<html><head><title>Mysql</title></head><body>");
> 			writer.println("Mysql OL Testing.<br><br>");
> 			System.err.println("SERVLET: Calling " +
> THREAD_COUNT + " threads.");
> 			for(int i = 0; i < THREAD_COUNT; i++){
> 				ClientAdder ca = new ClientAdder();
> 				System.err.println("SERVELET:  Creating
> thread " + i);
> 				threads[i] = ca;
> 				ca.start();
> 			}
> 			try {
> 				for (int i = 0; i < THREAD_COUNT; i++) {
> 					System.err.println("SERVLET:
> Joining to Thread " + i);
> 					threads[i].join();
> 				}
> 			}
> 			catch (InterruptedException e) {
> 				// fall through
> 			}
> 			printClientRelationships(req, resp);
> 			System.err.println("SERVLET: Done.");
> 
> 			writer.println("</body></html>");
> 
> 	}
> 
> 	protected void doGet(HttpServletRequest req, HttpServletResponse
> resp)
> 		throws ServletException, IOException {
> 		doPost(req, resp);
> 	}
> 	
> 	protected void printClientRelationships(HttpServletRequest req,
> HttpServletResponse resp) throws IOException{
> 		PrintWriter writer = resp.getWriter();
> 		Query query = new
> QueryByCriteria(ClientRelationship.class, null);
> 		try{
> 			PersistenceBroker broker =
> PersistenceBrokerFactory.createPersistenceBroker("default", "user",
> "password");
> 			Collection allClients =
> broker.getCollectionByQuery(query);
> 			Iterator iter = allClients.iterator();
> 			while (iter.hasNext()){
> 				ClientRelationship cr =
> (ClientRelationship) iter.next();
> 				writer.println(cr.getName() + "<br>");
> 			}
> 			broker.close();
> 		}
> 		catch (Throwable t){
> 			t.printStackTrace();
> 		}
> 	}	
> }
> 
> The Thread class:
> public class ClientAdder extends Thread {
> 	private static PersistenceBroker broker = null;
> 	private static String clientName = "";
> 	
> 	public void run(){
> 		//This thread starts a transactions, finds the largest
> name currently in the database,
> 		//increments the name by one, inserts a new row, and
> then commits the transaction
> 		System.err.println("THREAD:  Running");
> 		broker =
> PersistenceBrokerFactory.createPersistenceBroker("default", "user",
> "password");
> 		broker.beginTransaction();
> 		Query query = new QueryBySQL(ClientRelationship.class,
> "select * from dexa900t order by name");
> 		Collection c = broker.getCollectionByQuery(query);
> 		Iterator i = c.iterator();
> 		System.err.println("THREAD:  have collection from DB");
> 		setClientName("");
> 		while(i.hasNext()){
> 			ClientRelationship bleh = (ClientRelationship)
> i.next();
> 			if(bleh.getName().compareTo(getClientName()) >
> 0){
> 				setClientName(bleh.getName());
> 			}
> 		}
> 		if((getClientName() == null) ||
> getClientName().equals("")){
> 			System.err.println("THREAD:  Database has no
> current clients.");
> 			setClientName("00000");
> 		}
> 		else{
> 			int n = (new
> Integer(getClientName())).intValue();
> 			n++;
> 			setClientName("");
> 			if(n < 10000){
> 				setClientName("0" + getClientName()); 
> 			}
> 			if(n < 1000){
> 				setClientName("0" + getClientName());
> 			}
> 			if(n < 100){
> 				setClientName("0" + getClientName());
> 			}
> 			if(n < 10){
> 				setClientName("0" + getClientName());
> 			}
> 			setClientName(getClientName() + (new
> Integer(n)).toString());
> 		}						
> 
> 		System.err.println("THREAD:  Adding " +
> getClientName());
> 		ClientRelationship cr = new ClientRelationship();
> 		cr.setName(getClientName());
> 		cr.setCreatedUser("N0000000");
> 		cr.setCreateDate(new Timestamp(0));
> 		cr.setDeleted(false);			
> 		broker.store(cr);		
> 		broker.commitTransaction();
> 		if(broker != null){
> 			broker.close();
> 		}
> 	}
> 	
> 	public ClientAdder (){
> 	}
> 	......
> 	Getters and Setters
> }
> 
> Repository.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- This is a sample metadata repository for the 
>      Apache ObJectRelationalBridge (OJB) System.
>      Use this file as a template for building your own mappings.
> -->
> 
> <!-- doctype definition
>      By default we are using a local DTD that is expected to reside
>      in the same directory as this repository.xml file.
>      If you intend to validate your repository.xml against
>      the public dtd at the Apache site, please replace the string
>      "repository.dtd" 
>      by the public adress
>      "http://db.apache.org/ojb/dtds/1.0/repository.dtd".
>      In this case validation will only work if the machine you
>      run your application on can connect to the internet! 
> -->
>      
> <!DOCTYPE descriptor-repository PUBLIC
>        "-//Apache Software Foundation//DTD OJB Repository//EN"
>        "repository.dtd"
> [
> <!ENTITY database SYSTEM "repository_database.xml">
> <!ENTITY internal SYSTEM "repository_internal.xml">
> <!ENTITY user SYSTEM "repository_user.xml">
> ]>
> 
> 
> <descriptor-repository version="1.0"
> isolation-level="read-uncommitted">
> 
>     <!-- include all used database connections -->
>     <jdbc-connection-descriptor
>         jcd-alias="default"
>         default-connection="true"
>         platform="MySQL"
>         jdbc-level="1.0"
>         jndi-datasource-name="jdbc/ao79"
>         batch-mode="false"
>     >
>         <sequence-manager
> className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeIm
> pl">
>            <attribute attribute-name="autoNaming"
> attribute-value="true"/>
>         </sequence-manager>
>     </jdbc-connection-descriptor>
> 
>     <!-- include ojb internal mappings here -->
>     <!-- &internal; -->
> 
>     <!-- include user defined mappings here -->
> <class-descriptor
>    	  class="model.ClientRelationship"
>    	  table="dexa900t"
>    >
>       <field-descriptor
>          name="relationshipId"
>          column="relationship_id"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>       <field-descriptor
>          name="name"
>          column="NAME"
>          jdbc-type="VARCHAR"
>       />
>       <field-descriptor
>       	name="createdUser"
>       	column="create_user"
>       	jdbc-type="VARCHAR"
>       	/>
>       <field-descriptor
>       	name="createDate"
>       	column="create_dtm"
>       	jdbc-type="TIMESTAMP"
>       	/>
>       <field-descriptor
>       	name="deleted"
>       	column="delete_flag"
>       	jdbc-type="CHAR"
>       	conversion="persitence.Boolean2CharFieldConversion"
>       	/>
>       <field-descriptor
>       	name="optLockField"
>       	column="opt_lock_field"
>       	jdbc-type="INTEGER"
>       	locking="true"
>       	/>
>     </class-descriptor>
> 
> </descriptor-repository>
> 
> The OJB.properties file:
> 
> # OJB.properties -- configuration of the OJB runtime environment
> # Version: 1.0
> # (c) 2001, 2002, 2003 Apache Software Foundation
> # Author: Thomas Mahler and many others
> #
> #---------------------------------------------------------------------
> -------------------
> # repository file settings
> #---------------------------------------------------------------------
> -------------------
> # The repositoryFile entry tells OJB to use this file as as its
> standard mapping
> # repository. The file is looked up from the classpath.
> #
> repositoryFile=repository.xml
> #
> # If the useSerializedRepository entry is set to true, OJB tries to
> load a
> # serialized version of the repository for performance reasons.
> # if set to false, OJB always loads the xml file.
> # Setting this flag to true will accelerate the startup sequence of
> OJB.
> # If set to true changes to the repository.xml file will only be
> detected
> # after maually deleting the repository.xml.serialized file.
> useSerializedRepository=false
> #
> # If Repository serialization is used the entry
> serializedRepositoryPath defines the
> # directory where the Repository is written to and read from.
> # this entry is used only when the useSerializedRepository flag is set
> to true
> #
> serializedRepositoryPath=.
> #
> #---------------------------------------------------------------------
> -------------------
> # PersistenceBrokerFactory / PersistenceBroker
> #---------------------------------------------------------------------
> -------------------
> # The PersistenceBrokerFactoryClass entry decides which concrete
> # PersistenceBrokerFactory implemention is to be used.
> PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBr
> okerFactoryDefaultImpl
> #
> # The PersistenceBrokerClass entry decides which concrete
> PersistenceBroker
> # implementation is to be served by the PersistenceBrokerFactory.
> # This is the singlevm implementation:
> PersistenceBrokerClass=org.apache.ojb.broker.core.PersistenceBrokerImp
> l
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # PersistenceBrokerFactory pool
> #---------------------------------------------------------------------
> -------------------
> # PersistenceBroker pool configuration
> # This pool uses the jakarta-commons-pool api.
> # There you can find things described in detail.
> #
> # maximum number of brokers that can be borrowed from the
> # pool at one time. When non-positive, there is no limit.
> maxActive=100
> #
> # controls the maximum number of brokers that can sit idle in the
> # pool (per key) at any time. When non-positive, there is no limit
> maxIdle=-1
> #
> # max time block to get broker instance from pool, after that
> exception is thrown.
> # When non-positive, block till last judgement
> maxWait=2000
> #
> # indicates how long the eviction thread should sleep before "runs" of
> examining
> # idle objects. When non-positive, no eviction thread will be
> launched.
> timeBetweenEvictionRunsMillis=-1
> #
> # specifies the minimum amount of time that an broker may sit idle
> # in the pool before it is eligable for eviction due to idle time.
> # When non-positive, no object will be dropped from the pool due
> # to idle time alone (depends on timeBetweenEvictionRunsMillis > 0)
> minEvictableIdleTimeMillis=1000000
> #
> # specifies the behaviour of the pool when broker capacity is
> # exhausted (see maxActive above)
> # 0 - fail
> # 1 - block
> # 2 - grow
> whenExhaustedAction=0
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # ConnectionFactory / Default ConnectionPool
> #---------------------------------------------------------------------
> -------------------
> # The ConnectionFactoryClass entry determines which kind of
> ConnectionFactory
> # is to be used within org.apache.ojb as connection factory.
> # A ConnectionFactory is responsible for creating
> # JDBC Connections. Current version ships four implementations:
> #
> # 1. ConnectionFactoryNotPooledImpl
> #    No pooling, no playing around.
> #    Every connection request returns a new connection,
> #    every connection release close the connection.
> # 2. ConnectionFactoryPooledImpl
> #    This implementation supports connection pooling.
> # 3. ConnectionFactoryDBCPImpl
> #    Using the jakarta-DBCP api for connection management, support
> #    connection- and prepared statement-pooling, abandoned connection
> handling.
> # 4. ConnectionFactoryManagedImpl
> #    Connection factory for use within managed environments - e.g.
> JBoss.
> #    Every obtained DataSource was wrapped within OJB (and ignore
> #    e.g. con.commit() calls within OJB).
> #    Use this implementation e.g if you use Datasources from an
> application server.
> #
> # Use the OJB performance tests to decide, which implementation is
> best for you.
> # The proper way of obtaining a connection is configured in
> # JDBCConnectionDescriptor entries in the repository.xml file.
> # If want a more fine grained control of each connection pool used by
> OJB,
> # take a look at the repository.dtd, there was a possibility to
> override
> # this default connection factory entry in each
> JDBCConnectionDescriptor.
> #
> ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFac
> toryPooledImpl
> #ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFa
> ctoryNotPooledImpl
> #ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFa
> ctoryManagedImpl
> #ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFa
> ctoryDBCPImpl
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # ConnectionManager
> #---------------------------------------------------------------------
> -------------------
> # The ConnectionManagerClass entry defines the ConnectionManager
> implemementation to be used
> ConnectionManagerClass=org.apache.ojb.broker.accesslayer.ConnectionMan
> agerImpl
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # SqlGenerator
> #---------------------------------------------------------------------
> -------------------
> # The SqlGeneratorClass entry defines the SqlGenerator
> implemementation to be used
> SqlGeneratorClass=org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDe
> faultImpl
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # CollectionProxy class
> #---------------------------------------------------------------------
> -------------------
> # The optional CollectionProxy entry defines the class to be used for
> CollectionProxies
> # if this entry is null org.apache.ojb.broker.accesslayer.ListProxy is
> used for Lists
> # and org.apache.ojb.broker.accesslayer.CollectionProxy for
> Collections
> #
> #CollectionProxyClass=
> #
> #---------------------------------------------------------------------
> -------------------
> # StatementManager
> #---------------------------------------------------------------------
> -------------------
> # The StatementManagerClass entry defines the StatementManager
> implemementation to be used
> StatementManagerClass=org.apache.ojb.broker.accesslayer.StatementManag
> er
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # StatementsForClass
> #---------------------------------------------------------------------
> -------------------
> # The StatementsForClassClass entry defines the StatementsForClass
> implemementation to be used
> # to implement cached statements.
> StatementsForClassClass=org.apache.ojb.broker.accesslayer.StatementsFo
> rClassImpl
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # JdbcAccess
> #---------------------------------------------------------------------
> -------------------
> # The JdbcAccessClass entry defines the JdbcAccess implemementation to
> be used
> JdbcAccessClass=org.apache.ojb.broker.accesslayer.JdbcAccessImpl
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # Object cache
> #---------------------------------------------------------------------
> -------------------
> # The ObjectCacheClass entry tells OJB which concrete instance Cache
> # implementation is to be used.
> #ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
> #ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl
> #ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
> ObjectCacheClass=persitence.ObjectCacheOSCacheImpl
> #ObjectCacheClass=org.apache.ojb.broker.cache.MetaObjectCacheJCSImpl
> #ObjectCacheClass=org.apache.ojb.broker.cache.MetaObjectCachePerClassI
> mpl
> #
> #
> # Use CacheFilters to do filter operations before caching methods were
> # called. Build your own filter class by implementing
> org.apache.ojb.cache.CacheFilter.
> # It is possible to use a arbitrary number of CacheFilters, but this
> slows
> # down the performance of the cache, thus handle with care.
> #
> # - org.apache.ojb.broker.cache.CacheFilterClassImpl
> # allows filtering of classes
> # - org.apache.ojb.broker.cache.CacheFilterPackageImpl
> # allows filtering of packages
> # More info see Javadoc of the according classes.
> # Set a comma separated list of CacheFilter.
> #ObjectCacheFilter=org.apache.ojb.broker.cache.CacheFilterClassImpl,or
> g.apache.ojb.broker.cache.CacheFilterPackageImpl
> #
> #---------------------------------------------------------------------
> -------------------
> # Locking
> #---------------------------------------------------------------------
> -------------------
> # The LockManagerClass entry tells OJB which concrete LockManager
> # implementation is to be used.
> LockManagerClass=org.apache.ojb.odmg.locking.LockManagerDefaultImpl
> #
> # The LockMapClass entry tells OJB which concrete LockMap
> # implementation is to be used.
> # If OJB is running on multiple concurrent clients it is recommended
> # to use the PersistentLockMapImpl. It guarantees to provide
> # Lockamanagement across multiple JVMs.
> # If OJB is running in a single JVM (e.g. in a desktop app, or in a
> servlet
> # engine) it is save to use the InMemoryLockMapImpl. Using it will
> result
> # in a large performance gain.
> # LockMapClass=org.apache.ojb.odmg.locking.PersistentLockMapImpl
> LockMapClass=org.apache.ojb.odmg.locking.InMemoryLockMapImpl
> #
> # The LockTimeout entry defines the maximum time in milliseconds
> # that a lock may be hold. Defaults to 60000 = 1 minute
> LockTimeout=60000
> #
> # The ImplicitLocking entry defines if implicit lock acquisition is
> # to be used. If set to true OJB implicitely locks objects to ODMG
> # transactions after performing OQL queries.
> # If implicit locking is used locking objects is recursive, that is
> # associated objects are also locked.
> # If ImplicitLocking is set to false, no locks are obtained in OQL
> # queries and there is also no recursive locking.
> ImplicitLocking=true
> #ImplicitLocking=false
> #
> # The LockAssociations entry defines the behaviour for the OJB
> # implicit locking feature. If set to WRITE (default) acquiring a
> write-
> # lock on a given object x implies write locks on all objects
> associated
> # to x. If set to READ implicit read-locks are acquired.
> # Acquiring a read-lock on x thus allways results in implicit
> read-locks
> # on all associated objects.
> #LockAssociations=READ
> LockAssociations=WRITE
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # Logging
> #---------------------------------------------------------------------
> -------------------
> # The LoggerClass entry tells OJB which concrete Logger
> # implementation is to be used.
> #
> # Commons-logging
> #LoggerClass=org.apache.ojb.broker.util.logging.CommonsLoggerImpl
> # log4j based logging
> #LoggerClass=org.apache.ojb.broker.util.logging.Log4jLoggerImpl
> # OJB's own simple looging support
> LoggerClass=org.apache.ojb.broker.util.logging.PoorMansLoggerImpl
> LoggerConfigFile=log4j.properties
> #
> # The LogLevel entries tells OJB which LogLevels are active
> # for the different loggers used within OJB
> # Loglevels: DEBUG < INFO < WARN < ERROR < FATAL
> # That is loglevel WARN won't log DEBUG and INFO messages,
> # but will log WARN, ERROR, and FATAL messages
> #
> # Global default log level used for all logging
> # entities if not specified
> ROOT.LogLevel=ERROR
> #
> # The Default Logger instance used within OJB
> DEFAULT.LogLevel=DEBUG
> # 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 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
> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.LogLevel=WARN
> # Logger for RsIterator, useful for debugging problems with Object
> materialization
> org.apache.ojb.broker.accesslayer.RsIterator.LogLevel=WARN
> # Logger for StatementsForClass, useful for debugging JDBC Connection
> related problems
> org.apache.ojb.broker.accesslayer.StatementsForClassImpl.LogLevel=WARN
> # Logger for SqlGenerator, useful for debugging generation of SQL
> 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.LogLeve
> l=WARN
> # Logger for ConnectionFactory
> org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.LogLev
> el=WARN
> #
> # Special Logger categories used in test suite and tutorials
> #
> # Logger for the ODMG Implementation
> ODMG.LogLevel=WARN
> # Logger for the JDO RI Implementation
> JDO.LogLevel=DEBUG
> # Logger for the performance tests
> performance.LogLevel=INFO
> # Logger for the soda api
> soda.LogLevel=WARN
> # Logger for the factory service
> ConfigurableFactory.LogLevel=WARN
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # OQL / SQL settings
> #---------------------------------------------------------------------
> -------------------
> # 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.
> # 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.broker.util.collections.ManageableAr
> rayList
> # OqlCollectionClass=org.apache.ojb.broker.util.ManageableVector
> #
> # The SqlInLimit entry limits the number of values in IN-sql
> statement,
> # -1 for no limits. This hint is used in Criteria.
> SqlInLimit=200
> #
> #
> #---------------------------------------------------------------------
> -------------------
> # Meta data / mapping settings
> #---------------------------------------------------------------------
> -------------------
> # The PersistentFieldClass property defines the implementation class
> # for PersistentField attributes used in the OJB MetaData layer.
> # By default the best performing attribute/refection based
> implementation
> # is selected (PersistentFieldDirectAccessImpl).
> #
> # - PersistentFieldDirectAccessImpl
> #   is a high-speed version of the access strategies.
> #   It does not cooperate with an AccessController,
> #   but accesses the fields directly. Persistent
> #   attributes don't need getters and setters
> #   and don't have to be declared public or protected
> # - PersistentFieldPrivilegedImpl
> #   Same as above, but does cooperate with AccessController and do not
> #   suppress the java language access check.
> # - PersistentFieldIntrospectorImpl
> #   uses JavaBeans compliant calls only to access persistent
> attributes.
> #   No Reflection is needed. But for each attribute xxx there must be
> #   public getXxx() and setXxx() methods.
> # - PersistentFieldDynaBeanAccessImpl
> #   implementation used to access a property from a
> #   org.apache.commons.beanutils.DynaBean.
> #
> PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persis
> tentFieldDirectAccessImpl
> #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
> stentFieldPrivilegedImpl
> #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
> stentFieldIntrospectorImpl
> #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
> stentFieldDynaBeanAccessImpl
> #
> # outdated deprecated versions:
> #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
> stentFieldMaxPerformanceImpl
> #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
> stentNestedFieldMaxPerformanceImpl
> #PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
> stentFieldPropertyImpl
> #
> #---------------------------------------------------------------------
> -------------------
> # Component Intercepting for Profiling and Tracing
> #---------------------------------------------------------------------
> -------------------
> # By enabling an InterceptorClass all OJB components will use
> # this Interceptor. Interceptors allow advanced tracing and Profiling
> # of all component method calls.
> # This is currently an experimental feature useful only for OJB kernel
> developers.
> #
> #InterceptorClass=org.apache.ojb.broker.util.interceptor.TracingInterc
> eptor
> #
> #---------------------------------------------------------------------
> -------------------
> # Transaction Management and assocation
> #---------------------------------------------------------------------
> -------------------
> # Use the LocalTxManager if you want the transaction to be associated
> by a thread
> OJBTxManagerClass=org.apache.ojb.odmg.LocalTxManager
> # Use the JTATxManager if you want the transaction to be associated
> via the Transaction
> # manager that is in your application server.
> #OJBTxManagerClass=org.apache.ojb.odmg.JTATxManager
> #
> # The TransactionManager is acquired in different ways dependent on
> the application server.
> # The JTATransactionManagerClass property allows you to specify the
> class that implements
> # the proper behaviour for finding the transaction manager. Only use
> when OJBTxManagerClass
> # is set to a factory that uses the application server transaction
> manager
> # (org.apache.ojb.odmg.JTATxManager)
> #
> # JBoss Transaction Manager Factory
> JTATransactionManagerClass=org.apache.ojb.odmg.transaction.JBossTransa
> ctionManagerFactory
> # Weblogic Transaction Manager Factory
> #JTATransactionManagerClass=org.apache.ojb.odmg.transaction.WeblogicTr
> ansactionManagerFactory
> # WebSphere transaction manager factory
> #JTATransactionManagerClass=org.apache.ojb.odmg.transaction.WebSphereT
> ransactionManagerFactory
> # Orion transaction manager factory
> #JTATransactionManagerClass=org.apache.ojb.odmg.transaction.OrionTrans
> actionManagerFactory
> #
> #---------------------------------------------------------------------
> -------------------
> # End of OJB.properties file
> #---------------------------------------------------------------------
> -------------------
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


PersistenceBrokerException - out of memory

Posted by Paul Joseph <pj...@yahoo.com>.
Hi,

I have a query that retrives about 250 rows of data.

After I run it about 10 times, it fails to run and an
examination of the Tomcat logs indicates that it ran
out of memory.

I am using Sun's JDO reference implementation.... and
calling it from a Cocoon flow script, using the method
I copied from the Apache DB site example:

public Object[] getObjectList(JdoPMF pmf, Object obj,
String filter, String ordering) {
    Criteria criteria = null;
    Collection objects = null;
    PersistenceManager pm =
pmf.getPersistenceManager();
    PersistenceBroker broker = null;
    if(obj == null)
        return null;
    try {
		broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
		broker.clearCache();
        System.out.println("Filter is: " + filter);
	    System.out.println("Ordering is: " + ordering);
        Query query = pm.newQuery(obj.getClass(),
filter);
	    System.out.println("Filter is: " + filter);
	    if(ordering!=null)
	        query.setOrdering(ordering);
	        System.out.println("Ordering is: " +
ordering);
        pm.currentTransaction().begin();
	    objects = (Collection)query.execute();
	    pm.currentTransaction().commit();
	} catch (Exception sqle) {
		sqle.printStackTrace();
	    String msg = sqle.getMessage();
		return null;
	}
	if(broker != null)
	{
	  broker.close();                                    
        // Release broker instance to the broker-pool
    }
	return objects.toArray();
}

When I pass in the persistenmanager instead of the
factory, then it does slightly better - 35 times
before it breaks with the same error.

I bumped up the JVM heapsize as follows, but it seemed
to have *zero* effect (in Catalina50.bat):

set JAVA_OPTS=-Xms128m -Xmx400m

I also am using the default cache implementation with
clearing of cache specified at 5 secs. in my
repository.xml as follows:

<object-cache
class="org.apache.ojb.broker.cache.ObjectCacheDefaultImpl">
<attribute attribute-name="timeout"
attribute-value="5"/>
</object-cache>
        <connection-pool maxActive="25"
validationQuery="" />
        <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl"
/>
   </jdbc-connection-descriptor>


Any help would be much appreciated!!

I am running on XP with Tomcat 5.2x and JDK1.4

thx
Paul

==========
[JDO] DEBUG: OjbStoreConnector.begin:
connectionReadyForRelease=false
java.lang.OutOfMemoryError
org.apache.ojb.broker.PersistenceBrokerException:
java.lang.OutOfMemoryError
	at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown
Source)
	at
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown
Source)
	at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown
Source)
	at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown
Source)
	at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown
Source)
	at org.apache.ojb.jdori.sql.OjbExtent.<init>(Unknown
Source)
	at
org.apache.ojb.jdori.sql.OjbStoreManager.getExtent(Unknown
Source)
	at
com.sun.jdori.common.PersistenceManagerImpl.getExtent(Unknown
Source)
	at
com.sun.jdori.common.query.QueryImpl.checkCandidates(Unknown
Source)
	at
com.sun.jdori.common.query.QueryImpl.execute(Unknown
Source)
	at
org.apache.cocoon.ojb.samples.SuperDAO.getObjectList(SuperDAO.java:227)
	at
sun.reflect.GeneratedMethodAccessor137.invoke(Unknown
Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
	at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:1134)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:702)
	at
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:130)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:103)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:103)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:639)
	at
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1098)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
	at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.OutOfMemoryError



=====
This communication, including attachments, is for the exclusive use of 
the addressee and may contain proprietary, confidential, or privileged
information.  If you are not the intended recipient, any use, copying,
disclosure, dissemination, or distribution is strictly prohibited.  If 
you are not the intended recipient, please notify the sender by return mail and delete this communication and destroy all copies.

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: OJB, Optimistic Locking, and multiple threads

Posted by Armin Waibel <ar...@apache.org>.
Hi Wes,

public class ClientAdder extends Thread {
 > 	private static PersistenceBroker broker = null;
 > 	private static String clientName = "";

I don't understand why you are use a static reference to PB in 
ClientAdder. Think this will cause concurrent problems and PB itself is 
not thread safe. Do I miss something?

regards,
Armin


Lemke, Wesley wrote:

>>We are currently using OJB, with a single JVM, but we are planning on
>>going to a clustered environment.  I was doing some testing of just
>>one class with a few fields that maps to one table.  Instead of
>>running multiple applications on multiple JVMs, I thought it would be
>>easier to have one application spawn several threads, and each of the
>>threads persist a different object.  If I run one Thread everything
>>works fine, but when I increase the number of threads I get an
>>OptimisticLockException.  I followed the clustering how-to to get
>>everything set up.  Should this work the same with multiple threads as
>>it would with multiple JVMs?  If so can someone let me know what I am
>>doing wrong?  
>>
>>I'll put the relevant code/mapping below.  Let me know if anything
>>else would be helpful to see.
>>
>>Thanks,
>>Wes
>>
>>The servlet class:  
>>public class WesServlet extends HttpServlet {
>>	private static final int THREAD_COUNT = 3;
>>	private static ClientAdder[] threads = null;
>>	
>>	protected void doPost(HttpServletRequest req,
>>HttpServletResponse resp)
>>		throws ServletException, IOException {
>>			threads = new ClientAdder[THREAD_COUNT];
>>
>>			PrintWriter writer = resp.getWriter();
>>	
>>writer.println("<html><head><title>Mysql</title></head><body>");
>>			writer.println("Mysql OL Testing.<br><br>");
>>			System.err.println("SERVLET: Calling " +
>>THREAD_COUNT + " threads.");
>>			for(int i = 0; i < THREAD_COUNT; i++){
>>				ClientAdder ca = new ClientAdder();
>>				System.err.println("SERVELET:  Creating
>>thread " + i);
>>				threads[i] = ca;
>>				ca.start();
>>			}
>>			try {
>>				for (int i = 0; i < THREAD_COUNT; i++) {
>>					System.err.println("SERVLET:
>>Joining to Thread " + i);
>>					threads[i].join();
>>				}
>>			}
>>			catch (InterruptedException e) {
>>				// fall through
>>			}
>>			printClientRelationships(req, resp);
>>			System.err.println("SERVLET: Done.");
>>
>>			writer.println("</body></html>");
>>
>>	}
>>
>>	protected void doGet(HttpServletRequest req, HttpServletResponse
>>resp)
>>		throws ServletException, IOException {
>>		doPost(req, resp);
>>	}
>>	
>>	protected void printClientRelationships(HttpServletRequest req,
>>HttpServletResponse resp) throws IOException{
>>		PrintWriter writer = resp.getWriter();
>>		Query query = new
>>QueryByCriteria(ClientRelationship.class, null);
>>		try{
>>			PersistenceBroker broker =
>>PersistenceBrokerFactory.createPersistenceBroker("default", "user",
>>"password");
>>			Collection allClients =
>>broker.getCollectionByQuery(query);
>>			Iterator iter = allClients.iterator();
>>			while (iter.hasNext()){
>>				ClientRelationship cr =
>>(ClientRelationship) iter.next();
>>				writer.println(cr.getName() + "<br>");
>>			}
>>			broker.close();
>>		}
>>		catch (Throwable t){
>>			t.printStackTrace();
>>		}
>>	}	
>>}
>>
>>The Thread class:
>>public class ClientAdder extends Thread {
>>	private static PersistenceBroker broker = null;
>>	private static String clientName = "";
>>	
>>	public void run(){
>>		//This thread starts a transactions, finds the largest
>>name currently in the database,
>>		//increments the name by one, inserts a new row, and
>>then commits the transaction
>>		System.err.println("THREAD:  Running");
>>		broker =
>>PersistenceBrokerFactory.createPersistenceBroker("default", "user",
>>"password");
>>		broker.beginTransaction();
>>		Query query = new QueryBySQL(ClientRelationship.class,
>>"select * from dexa900t order by name");
>>		Collection c = broker.getCollectionByQuery(query);
>>		Iterator i = c.iterator();
>>		System.err.println("THREAD:  have collection from DB");
>>		setClientName("");
>>		while(i.hasNext()){
>>			ClientRelationship bleh = (ClientRelationship)
>>i.next();
>>			if(bleh.getName().compareTo(getClientName()) >
>>0){
>>				setClientName(bleh.getName());
>>			}
>>		}
>>		if((getClientName() == null) ||
>>getClientName().equals("")){
>>			System.err.println("THREAD:  Database has no
>>current clients.");
>>			setClientName("00000");
>>		}
>>		else{
>>			int n = (new
>>Integer(getClientName())).intValue();
>>			n++;
>>			setClientName("");
>>			if(n < 10000){
>>				setClientName("0" + getClientName()); 
>>			}
>>			if(n < 1000){
>>				setClientName("0" + getClientName());
>>			}
>>			if(n < 100){
>>				setClientName("0" + getClientName());
>>			}
>>			if(n < 10){
>>				setClientName("0" + getClientName());
>>			}
>>			setClientName(getClientName() + (new
>>Integer(n)).toString());
>>		}						
>>
>>		System.err.println("THREAD:  Adding " +
>>getClientName());
>>		ClientRelationship cr = new ClientRelationship();
>>		cr.setName(getClientName());
>>		cr.setCreatedUser("N0000000");
>>		cr.setCreateDate(new Timestamp(0));
>>		cr.setDeleted(false);			
>>		broker.store(cr);		
>>		broker.commitTransaction();
>>		if(broker != null){
>>			broker.close();
>>		}
>>	}
>>	
>>	public ClientAdder (){
>>	}
>>	......
>>	Getters and Setters
>>}
>>
>>Repository.xml
>><?xml version="1.0" encoding="UTF-8"?>
>><!-- This is a sample metadata repository for the 
>>     Apache ObJectRelationalBridge (OJB) System.
>>     Use this file as a template for building your own mappings.
>>-->
>>
>><!-- doctype definition
>>     By default we are using a local DTD that is expected to reside
>>     in the same directory as this repository.xml file.
>>     If you intend to validate your repository.xml against
>>     the public dtd at the Apache site, please replace the string
>>     "repository.dtd" 
>>     by the public adress
>>     "http://db.apache.org/ojb/dtds/1.0/repository.dtd".
>>     In this case validation will only work if the machine you
>>     run your application on can connect to the internet! 
>>-->
>>     
>><!DOCTYPE descriptor-repository PUBLIC
>>       "-//Apache Software Foundation//DTD OJB Repository//EN"
>>       "repository.dtd"
>>[
>><!ENTITY database SYSTEM "repository_database.xml">
>><!ENTITY internal SYSTEM "repository_internal.xml">
>><!ENTITY user SYSTEM "repository_user.xml">
>>]>
>>
>>
>><descriptor-repository version="1.0"
>>isolation-level="read-uncommitted">
>>
>>    <!-- include all used database connections -->
>>    <jdbc-connection-descriptor
>>        jcd-alias="default"
>>        default-connection="true"
>>        platform="MySQL"
>>        jdbc-level="1.0"
>>        jndi-datasource-name="jdbc/ao79"
>>        batch-mode="false"
>>    >
>>        <sequence-manager
>>className="org.apache.ojb.broker.util.sequence.SequenceManagerNativeIm
>>pl">
>>           <attribute attribute-name="autoNaming"
>>attribute-value="true"/>
>>        </sequence-manager>
>>    </jdbc-connection-descriptor>
>>
>>    <!-- include ojb internal mappings here -->
>>    <!-- &internal; -->
>>
>>    <!-- include user defined mappings here -->
>><class-descriptor
>>   	  class="model.ClientRelationship"
>>   	  table="dexa900t"
>>   >
>>      <field-descriptor
>>         name="relationshipId"
>>         column="relationship_id"
>>         jdbc-type="INTEGER"
>>         primarykey="true"
>>         autoincrement="true"
>>      />
>>      <field-descriptor
>>         name="name"
>>         column="NAME"
>>         jdbc-type="VARCHAR"
>>      />
>>      <field-descriptor
>>      	name="createdUser"
>>      	column="create_user"
>>      	jdbc-type="VARCHAR"
>>      	/>
>>      <field-descriptor
>>      	name="createDate"
>>      	column="create_dtm"
>>      	jdbc-type="TIMESTAMP"
>>      	/>
>>      <field-descriptor
>>      	name="deleted"
>>      	column="delete_flag"
>>      	jdbc-type="CHAR"
>>      	conversion="persitence.Boolean2CharFieldConversion"
>>      	/>
>>      <field-descriptor
>>      	name="optLockField"
>>      	column="opt_lock_field"
>>      	jdbc-type="INTEGER"
>>      	locking="true"
>>      	/>
>>    </class-descriptor>
>>
>></descriptor-repository>
>>
>>The OJB.properties file:
>>
>># OJB.properties -- configuration of the OJB runtime environment
>># Version: 1.0
>># (c) 2001, 2002, 2003 Apache Software Foundation
>># Author: Thomas Mahler and many others
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># repository file settings
>>#---------------------------------------------------------------------
>>-------------------
>># The repositoryFile entry tells OJB to use this file as as its
>>standard mapping
>># repository. The file is looked up from the classpath.
>>#
>>repositoryFile=repository.xml
>>#
>># If the useSerializedRepository entry is set to true, OJB tries to
>>load a
>># serialized version of the repository for performance reasons.
>># if set to false, OJB always loads the xml file.
>># Setting this flag to true will accelerate the startup sequence of
>>OJB.
>># If set to true changes to the repository.xml file will only be
>>detected
>># after maually deleting the repository.xml.serialized file.
>>useSerializedRepository=false
>>#
>># If Repository serialization is used the entry
>>serializedRepositoryPath defines the
>># directory where the Repository is written to and read from.
>># this entry is used only when the useSerializedRepository flag is set
>>to true
>>#
>>serializedRepositoryPath=.
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># PersistenceBrokerFactory / PersistenceBroker
>>#---------------------------------------------------------------------
>>-------------------
>># The PersistenceBrokerFactoryClass entry decides which concrete
>># PersistenceBrokerFactory implemention is to be used.
>>PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBr
>>okerFactoryDefaultImpl
>>#
>># The PersistenceBrokerClass entry decides which concrete
>>PersistenceBroker
>># implementation is to be served by the PersistenceBrokerFactory.
>># This is the singlevm implementation:
>>PersistenceBrokerClass=org.apache.ojb.broker.core.PersistenceBrokerImp
>>l
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># PersistenceBrokerFactory pool
>>#---------------------------------------------------------------------
>>-------------------
>># PersistenceBroker pool configuration
>># This pool uses the jakarta-commons-pool api.
>># There you can find things described in detail.
>>#
>># maximum number of brokers that can be borrowed from the
>># pool at one time. When non-positive, there is no limit.
>>maxActive=100
>>#
>># controls the maximum number of brokers that can sit idle in the
>># pool (per key) at any time. When non-positive, there is no limit
>>maxIdle=-1
>>#
>># max time block to get broker instance from pool, after that
>>exception is thrown.
>># When non-positive, block till last judgement
>>maxWait=2000
>>#
>># indicates how long the eviction thread should sleep before "runs" of
>>examining
>># idle objects. When non-positive, no eviction thread will be
>>launched.
>>timeBetweenEvictionRunsMillis=-1
>>#
>># specifies the minimum amount of time that an broker may sit idle
>># in the pool before it is eligable for eviction due to idle time.
>># When non-positive, no object will be dropped from the pool due
>># to idle time alone (depends on timeBetweenEvictionRunsMillis > 0)
>>minEvictableIdleTimeMillis=1000000
>>#
>># specifies the behaviour of the pool when broker capacity is
>># exhausted (see maxActive above)
>># 0 - fail
>># 1 - block
>># 2 - grow
>>whenExhaustedAction=0
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># ConnectionFactory / Default ConnectionPool
>>#---------------------------------------------------------------------
>>-------------------
>># The ConnectionFactoryClass entry determines which kind of
>>ConnectionFactory
>># is to be used within org.apache.ojb as connection factory.
>># A ConnectionFactory is responsible for creating
>># JDBC Connections. Current version ships four implementations:
>>#
>># 1. ConnectionFactoryNotPooledImpl
>>#    No pooling, no playing around.
>>#    Every connection request returns a new connection,
>>#    every connection release close the connection.
>># 2. ConnectionFactoryPooledImpl
>>#    This implementation supports connection pooling.
>># 3. ConnectionFactoryDBCPImpl
>>#    Using the jakarta-DBCP api for connection management, support
>>#    connection- and prepared statement-pooling, abandoned connection
>>handling.
>># 4. ConnectionFactoryManagedImpl
>>#    Connection factory for use within managed environments - e.g.
>>JBoss.
>>#    Every obtained DataSource was wrapped within OJB (and ignore
>>#    e.g. con.commit() calls within OJB).
>>#    Use this implementation e.g if you use Datasources from an
>>application server.
>>#
>># Use the OJB performance tests to decide, which implementation is
>>best for you.
>># The proper way of obtaining a connection is configured in
>># JDBCConnectionDescriptor entries in the repository.xml file.
>># If want a more fine grained control of each connection pool used by
>>OJB,
>># take a look at the repository.dtd, there was a possibility to
>>override
>># this default connection factory entry in each
>>JDBCConnectionDescriptor.
>>#
>>ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFac
>>toryPooledImpl
>>#ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFa
>>ctoryNotPooledImpl
>>#ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFa
>>ctoryManagedImpl
>>#ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFa
>>ctoryDBCPImpl
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># ConnectionManager
>>#---------------------------------------------------------------------
>>-------------------
>># The ConnectionManagerClass entry defines the ConnectionManager
>>implemementation to be used
>>ConnectionManagerClass=org.apache.ojb.broker.accesslayer.ConnectionMan
>>agerImpl
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># SqlGenerator
>>#---------------------------------------------------------------------
>>-------------------
>># The SqlGeneratorClass entry defines the SqlGenerator
>>implemementation to be used
>>SqlGeneratorClass=org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDe
>>faultImpl
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># CollectionProxy class
>>#---------------------------------------------------------------------
>>-------------------
>># The optional CollectionProxy entry defines the class to be used for
>>CollectionProxies
>># if this entry is null org.apache.ojb.broker.accesslayer.ListProxy is
>>used for Lists
>># and org.apache.ojb.broker.accesslayer.CollectionProxy for
>>Collections
>>#
>>#CollectionProxyClass=
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># StatementManager
>>#---------------------------------------------------------------------
>>-------------------
>># The StatementManagerClass entry defines the StatementManager
>>implemementation to be used
>>StatementManagerClass=org.apache.ojb.broker.accesslayer.StatementManag
>>er
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># StatementsForClass
>>#---------------------------------------------------------------------
>>-------------------
>># The StatementsForClassClass entry defines the StatementsForClass
>>implemementation to be used
>># to implement cached statements.
>>StatementsForClassClass=org.apache.ojb.broker.accesslayer.StatementsFo
>>rClassImpl
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># JdbcAccess
>>#---------------------------------------------------------------------
>>-------------------
>># The JdbcAccessClass entry defines the JdbcAccess implemementation to
>>be used
>>JdbcAccessClass=org.apache.ojb.broker.accesslayer.JdbcAccessImpl
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># Object cache
>>#---------------------------------------------------------------------
>>-------------------
>># The ObjectCacheClass entry tells OJB which concrete instance Cache
>># implementation is to be used.
>>#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
>>#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl
>>#ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
>>ObjectCacheClass=persitence.ObjectCacheOSCacheImpl
>>#ObjectCacheClass=org.apache.ojb.broker.cache.MetaObjectCacheJCSImpl
>>#ObjectCacheClass=org.apache.ojb.broker.cache.MetaObjectCachePerClassI
>>mpl
>>#
>>#
>># Use CacheFilters to do filter operations before caching methods were
>># called. Build your own filter class by implementing
>>org.apache.ojb.cache.CacheFilter.
>># It is possible to use a arbitrary number of CacheFilters, but this
>>slows
>># down the performance of the cache, thus handle with care.
>>#
>># - org.apache.ojb.broker.cache.CacheFilterClassImpl
>># allows filtering of classes
>># - org.apache.ojb.broker.cache.CacheFilterPackageImpl
>># allows filtering of packages
>># More info see Javadoc of the according classes.
>># Set a comma separated list of CacheFilter.
>>#ObjectCacheFilter=org.apache.ojb.broker.cache.CacheFilterClassImpl,or
>>g.apache.ojb.broker.cache.CacheFilterPackageImpl
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># Locking
>>#---------------------------------------------------------------------
>>-------------------
>># The LockManagerClass entry tells OJB which concrete LockManager
>># implementation is to be used.
>>LockManagerClass=org.apache.ojb.odmg.locking.LockManagerDefaultImpl
>>#
>># The LockMapClass entry tells OJB which concrete LockMap
>># implementation is to be used.
>># If OJB is running on multiple concurrent clients it is recommended
>># to use the PersistentLockMapImpl. It guarantees to provide
>># Lockamanagement across multiple JVMs.
>># If OJB is running in a single JVM (e.g. in a desktop app, or in a
>>servlet
>># engine) it is save to use the InMemoryLockMapImpl. Using it will
>>result
>># in a large performance gain.
>># LockMapClass=org.apache.ojb.odmg.locking.PersistentLockMapImpl
>>LockMapClass=org.apache.ojb.odmg.locking.InMemoryLockMapImpl
>>#
>># The LockTimeout entry defines the maximum time in milliseconds
>># that a lock may be hold. Defaults to 60000 = 1 minute
>>LockTimeout=60000
>>#
>># The ImplicitLocking entry defines if implicit lock acquisition is
>># to be used. If set to true OJB implicitely locks objects to ODMG
>># transactions after performing OQL queries.
>># If implicit locking is used locking objects is recursive, that is
>># associated objects are also locked.
>># If ImplicitLocking is set to false, no locks are obtained in OQL
>># queries and there is also no recursive locking.
>>ImplicitLocking=true
>>#ImplicitLocking=false
>>#
>># The LockAssociations entry defines the behaviour for the OJB
>># implicit locking feature. If set to WRITE (default) acquiring a
>>write-
>># lock on a given object x implies write locks on all objects
>>associated
>># to x. If set to READ implicit read-locks are acquired.
>># Acquiring a read-lock on x thus allways results in implicit
>>read-locks
>># on all associated objects.
>>#LockAssociations=READ
>>LockAssociations=WRITE
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># Logging
>>#---------------------------------------------------------------------
>>-------------------
>># The LoggerClass entry tells OJB which concrete Logger
>># implementation is to be used.
>>#
>># Commons-logging
>>#LoggerClass=org.apache.ojb.broker.util.logging.CommonsLoggerImpl
>># log4j based logging
>>#LoggerClass=org.apache.ojb.broker.util.logging.Log4jLoggerImpl
>># OJB's own simple looging support
>>LoggerClass=org.apache.ojb.broker.util.logging.PoorMansLoggerImpl
>>LoggerConfigFile=log4j.properties
>>#
>># The LogLevel entries tells OJB which LogLevels are active
>># for the different loggers used within OJB
>># Loglevels: DEBUG < INFO < WARN < ERROR < FATAL
>># That is loglevel WARN won't log DEBUG and INFO messages,
>># but will log WARN, ERROR, and FATAL messages
>>#
>># Global default log level used for all logging
>># entities if not specified
>>ROOT.LogLevel=ERROR
>>#
>># The Default Logger instance used within OJB
>>DEFAULT.LogLevel=DEBUG
>># 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 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
>>org.apache.ojb.broker.accesslayer.JdbcAccessImpl.LogLevel=WARN
>># Logger for RsIterator, useful for debugging problems with Object
>>materialization
>>org.apache.ojb.broker.accesslayer.RsIterator.LogLevel=WARN
>># Logger for StatementsForClass, useful for debugging JDBC Connection
>>related problems
>>org.apache.ojb.broker.accesslayer.StatementsForClassImpl.LogLevel=WARN
>># Logger for SqlGenerator, useful for debugging generation of SQL
>>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.LogLeve
>>l=WARN
>># Logger for ConnectionFactory
>>org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.LogLev
>>el=WARN
>>#
>># Special Logger categories used in test suite and tutorials
>>#
>># Logger for the ODMG Implementation
>>ODMG.LogLevel=WARN
>># Logger for the JDO RI Implementation
>>JDO.LogLevel=DEBUG
>># Logger for the performance tests
>>performance.LogLevel=INFO
>># Logger for the soda api
>>soda.LogLevel=WARN
>># Logger for the factory service
>>ConfigurableFactory.LogLevel=WARN
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># OQL / SQL settings
>>#---------------------------------------------------------------------
>>-------------------
>># 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.
>># 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.broker.util.collections.ManageableAr
>>rayList
>># OqlCollectionClass=org.apache.ojb.broker.util.ManageableVector
>>#
>># The SqlInLimit entry limits the number of values in IN-sql
>>statement,
>># -1 for no limits. This hint is used in Criteria.
>>SqlInLimit=200
>>#
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># Meta data / mapping settings
>>#---------------------------------------------------------------------
>>-------------------
>># The PersistentFieldClass property defines the implementation class
>># for PersistentField attributes used in the OJB MetaData layer.
>># By default the best performing attribute/refection based
>>implementation
>># is selected (PersistentFieldDirectAccessImpl).
>>#
>># - PersistentFieldDirectAccessImpl
>>#   is a high-speed version of the access strategies.
>>#   It does not cooperate with an AccessController,
>>#   but accesses the fields directly. Persistent
>>#   attributes don't need getters and setters
>>#   and don't have to be declared public or protected
>># - PersistentFieldPrivilegedImpl
>>#   Same as above, but does cooperate with AccessController and do not
>>#   suppress the java language access check.
>># - PersistentFieldIntrospectorImpl
>>#   uses JavaBeans compliant calls only to access persistent
>>attributes.
>>#   No Reflection is needed. But for each attribute xxx there must be
>>#   public getXxx() and setXxx() methods.
>># - PersistentFieldDynaBeanAccessImpl
>>#   implementation used to access a property from a
>>#   org.apache.commons.beanutils.DynaBean.
>>#
>>PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persis
>>tentFieldDirectAccessImpl
>>#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
>>stentFieldPrivilegedImpl
>>#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
>>stentFieldIntrospectorImpl
>>#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
>>stentFieldDynaBeanAccessImpl
>>#
>># outdated deprecated versions:
>>#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
>>stentFieldMaxPerformanceImpl
>>#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
>>stentNestedFieldMaxPerformanceImpl
>>#PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.Persi
>>stentFieldPropertyImpl
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># Component Intercepting for Profiling and Tracing
>>#---------------------------------------------------------------------
>>-------------------
>># By enabling an InterceptorClass all OJB components will use
>># this Interceptor. Interceptors allow advanced tracing and Profiling
>># of all component method calls.
>># This is currently an experimental feature useful only for OJB kernel
>>developers.
>>#
>>#InterceptorClass=org.apache.ojb.broker.util.interceptor.TracingInterc
>>eptor
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># Transaction Management and assocation
>>#---------------------------------------------------------------------
>>-------------------
>># Use the LocalTxManager if you want the transaction to be associated
>>by a thread
>>OJBTxManagerClass=org.apache.ojb.odmg.LocalTxManager
>># Use the JTATxManager if you want the transaction to be associated
>>via the Transaction
>># manager that is in your application server.
>>#OJBTxManagerClass=org.apache.ojb.odmg.JTATxManager
>>#
>># The TransactionManager is acquired in different ways dependent on
>>the application server.
>># The JTATransactionManagerClass property allows you to specify the
>>class that implements
>># the proper behaviour for finding the transaction manager. Only use
>>when OJBTxManagerClass
>># is set to a factory that uses the application server transaction
>>manager
>># (org.apache.ojb.odmg.JTATxManager)
>>#
>># JBoss Transaction Manager Factory
>>JTATransactionManagerClass=org.apache.ojb.odmg.transaction.JBossTransa
>>ctionManagerFactory
>># Weblogic Transaction Manager Factory
>>#JTATransactionManagerClass=org.apache.ojb.odmg.transaction.WeblogicTr
>>ansactionManagerFactory
>># WebSphere transaction manager factory
>>#JTATransactionManagerClass=org.apache.ojb.odmg.transaction.WebSphereT
>>ransactionManagerFactory
>># Orion transaction manager factory
>>#JTATransactionManagerClass=org.apache.ojb.odmg.transaction.OrionTrans
>>actionManagerFactory
>>#
>>#---------------------------------------------------------------------
>>-------------------
>># End of OJB.properties file
>>#---------------------------------------------------------------------
>>-------------------
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org