OJB collections not getting cached
My apps has Domains that have a m:n relationship with Groups (although I only need to navigate from Domains to Groups). I am successfully using a collection-descriptor with an indirection table to do this. My problem is that this "memberships" collection is not being persisted as part of the Domain object. The memberships are there when the Domain is first fetched from the database, but when I cache it (to disk with OSCache, if that matters) and then retrieve it, memberships is null. I want a Domain to persist with references to its Groups - isn't that possible? Or do I have to make a Membership class and cache that too? Here's my setup right now: ... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ObjectCacheOSCacheImpl issue.
OK, that was the problem. Thanks. M. On Thu, 10 Feb 2005 07:53:27 +0100, Armin Waibel <[EMAIL PROTECTED]> wrote: > > > > So what's going on here? > > are you sure that "OSCache" is really used by OJB? You set the OSCache > in OJB.properties, but is a cache in repository_database.xml file > (object-cache element in in the jdbc-connection-descriptor) set too? Are > specific caches set for classes (object-cache element in class-descriptor)? > > regards, > Armin > > Michael Newton wrote: > > I wrote a test as you suggested and it actually passed for both > > ObjectCacheOSCacheImpl and for the ObjectCacheDefaultImpl > > > > I have print statements in the constructor, lookup, and cache methods > > in ObjectCacheOSCacheImpl. > > > > Here is my test: > > public void testCache () throws Exception { > > PersistenceBroker broker = > > PersistenceBrokerFactory.defaultPersistenceBroker(); > > Attribute a = new Attribute(); > > Identity oid = broker.serviceIdentity().buildIdentity(a); > > broker.serviceObjectCache().cache(oid, a); > > Attribute b = (Attribute) broker.serviceObjectCache().lookup(oid); > > assertNotNull(b); > > } > > > > > > and here is the output (running with ObjectCacheOSCacheImpl ) > > > > [junit] Testsuite: legion.service.CacheTest > > [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.472 sec > > [junit] - Standard Output --- > > [junit] OSCache constructor > > [junit] - > > > > No "OSCache lookup" or "OSCache cache" messages are printed, and > > OSCache does not write it's disk cache (although it creates the > > directory) > > > > So what's going on here? > > > > M. > > > > On Thu, 10 Feb 2005 02:32:42 +0100, Armin Waibel <[EMAIL PROTECTED]> wrote: > > > >>Hi Michael, > >> > >>Michael Newton wrote: > >> > >>>I'm trying to use OSCache with OJB as I need disk persistence. > >>> > >>>My setup is working great with the other cache implementations. > >>> > >>>I got ObjectCacheOSCacheImpl.java from the db-obj-1.0.1-contrib > >>>package, set up oscache-2.1, and set ObjectCacheClass to > >>>ObjectCacheOSCacheImpl in my config. > >>> > >>>When I run it I get the following error, where OJB appears to be > >>>trying to pass a Properties object to ObjectCacheOSCacheImpl's > >>>constuctor: > >>> > >>>java.lang.NoSuchMethodException: > >>>ObjectCacheOSCacheImpl.(org.apache.ojb.broker.PersistenceBroker, > >>>java.util.Properties) > >>> > >>>I see that the constructors that ObjectCacheOSCacheImpl does have are > >>>all empty, so just for fun I added an empty constructor with the > >>>profile that OJB was looking for. The Properties object that is passed > >>>is null, by the way. > >>> > >>>Once I added this constructor, OJB ran and was fetching data from the > >>>database. > >> > >>all ObjectCache implementations need a specific constructor expect an PB > >>and Properties type. Thus you be right. > >> > >> > >> > >>>I could also see log output from OSCache itself like > >>>"Creating cache". Also it created a disk cache directory on the > >>>system, but doesn't write any files there. > >>> > >>>OJB does not seem to be calling cache() or lookup() on > >>>ObjectCacheOSCacheImpl ( I put some logging in it to see if it was). > >>> > >> > >>hmm, if OJB never calls cache or lookup in ObjectCacheOSCacheImpl it > >>will never call these methods on all ObjectCache implementations, > >>because they are all handled in the same way. > >>Did you write a test case to check the cache? Something like > >> > >>Article a = new Article(); > >>Identity oid = broker.serviceIdentity().buildIdentity(a); > >>broker.serviceObjectCache().cache(oid, a); > >> > >>Article b = broker.serviceObjectCache().lookup(oid); > >>assertNotNull(b); > >> > >>This test should pass with ObjectCacheDefaultImpl and your > >>ObjectCacheOSCacheImpl too. > >> > >>regards, > >>Armin > >> > >> > >> > >>>Here are my ojb properties in case ther
Re: ObjectCacheOSCacheImpl issue.
I wrote a test as you suggested and it actually passed for both ObjectCacheOSCacheImpl and for the ObjectCacheDefaultImpl I have print statements in the constructor, lookup, and cache methods in ObjectCacheOSCacheImpl. Here is my test: public void testCache () throws Exception { PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); Attribute a = new Attribute(); Identity oid = broker.serviceIdentity().buildIdentity(a); broker.serviceObjectCache().cache(oid, a); Attribute b = (Attribute) broker.serviceObjectCache().lookup(oid); assertNotNull(b); } and here is the output (running with ObjectCacheOSCacheImpl ) [junit] Testsuite: legion.service.CacheTest [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.472 sec [junit] - Standard Output --- [junit] OSCache constructor [junit] - No "OSCache lookup" or "OSCache cache" messages are printed, and OSCache does not write it's disk cache (although it creates the directory) So what's going on here? M. On Thu, 10 Feb 2005 02:32:42 +0100, Armin Waibel <[EMAIL PROTECTED]> wrote: > Hi Michael, > > Michael Newton wrote: > > I'm trying to use OSCache with OJB as I need disk persistence. > > > > My setup is working great with the other cache implementations. > > > > I got ObjectCacheOSCacheImpl.java from the db-obj-1.0.1-contrib > > package, set up oscache-2.1, and set ObjectCacheClass to > > ObjectCacheOSCacheImpl in my config. > > > > When I run it I get the following error, where OJB appears to be > > trying to pass a Properties object to ObjectCacheOSCacheImpl's > > constuctor: > > > > java.lang.NoSuchMethodException: > > ObjectCacheOSCacheImpl.(org.apache.ojb.broker.PersistenceBroker, > > java.util.Properties) > > > > I see that the constructors that ObjectCacheOSCacheImpl does have are > > all empty, so just for fun I added an empty constructor with the > > profile that OJB was looking for. The Properties object that is passed > > is null, by the way. > > > > Once I added this constructor, OJB ran and was fetching data from the > > database. > > all ObjectCache implementations need a specific constructor expect an PB > and Properties type. Thus you be right. > > > > I could also see log output from OSCache itself like > > "Creating cache". Also it created a disk cache directory on the > > system, but doesn't write any files there. > > > > OJB does not seem to be calling cache() or lookup() on > > ObjectCacheOSCacheImpl ( I put some logging in it to see if it was). > > > > hmm, if OJB never calls cache or lookup in ObjectCacheOSCacheImpl it > will never call these methods on all ObjectCache implementations, > because they are all handled in the same way. > Did you write a test case to check the cache? Something like > > Article a = new Article(); > Identity oid = broker.serviceIdentity().buildIdentity(a); > broker.serviceObjectCache().cache(oid, a); > > Article b = broker.serviceObjectCache().lookup(oid); > assertNotNull(b); > > This test should pass with ObjectCacheDefaultImpl and your > ObjectCacheOSCacheImpl too. > > regards, > Armin > > > > Here are my ojb properties in case there is anything relevant there: > > repositoryFile=ojb_repository.xml > > useSerializedRepository=false > > serializedRepositoryPath=. > > PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl > > PersistenceBrokerClass=org.apache.ojb.broker.core.PersistenceBrokerImpl > > maxActive=100 > > maxIdle=-1 > > maxWait=2000 > > timeBetweenEvictionRunsMillis=-1 > > minEvictableIdleTimeMillis=100 > > whenExhaustedAction=0 > > ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl > > ConnectionManagerClass=org.apache.ojb.broker.accesslayer.ConnectionManagerImpl > > SqlGeneratorClass=org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl > > IndirectionHandlerClass=org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl > > ListProxyClass=org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl > > SetProxyClass=org.apache.ojb.broker.core.proxy.SetProxyDefaultImpl > > CollectionProxyClass=org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl > > StatementManagerClass=org.apache.ojb.broker.accesslayer.StatementManager > > StatementsForClassClass=org.apache.ojb.broker.accesslayer.StatementsForClassImpl > > JdbcAccessClass=org.apache.ojb.broker.accesslayer.Jdbc
ObjectCacheOSCacheImpl issue.
I'm trying to use OSCache with OJB as I need disk persistence. My setup is working great with the other cache implementations. I got ObjectCacheOSCacheImpl.java from the db-obj-1.0.1-contrib package, set up oscache-2.1, and set ObjectCacheClass to ObjectCacheOSCacheImpl in my config. When I run it I get the following error, where OJB appears to be trying to pass a Properties object to ObjectCacheOSCacheImpl's constuctor: java.lang.NoSuchMethodException: ObjectCacheOSCacheImpl.(org.apache.ojb.broker.PersistenceBroker, java.util.Properties) I see that the constructors that ObjectCacheOSCacheImpl does have are all empty, so just for fun I added an empty constructor with the profile that OJB was looking for. The Properties object that is passed is null, by the way. Once I added this constructor, OJB ran and was fetching data from the database. I could also see log output from OSCache itself like "Creating cache". Also it created a disk cache directory on the system, but doesn't write any files there. OJB does not seem to be calling cache() or lookup() on ObjectCacheOSCacheImpl ( I put some logging in it to see if it was). Here are my ojb properties in case there is anything relevant there: repositoryFile=ojb_repository.xml useSerializedRepository=false serializedRepositoryPath=. PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl PersistenceBrokerClass=org.apache.ojb.broker.core.PersistenceBrokerImpl maxActive=100 maxIdle=-1 maxWait=2000 timeBetweenEvictionRunsMillis=-1 minEvictableIdleTimeMillis=100 whenExhaustedAction=0 ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl ConnectionManagerClass=org.apache.ojb.broker.accesslayer.ConnectionManagerImpl SqlGeneratorClass=org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl IndirectionHandlerClass=org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl ListProxyClass=org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl SetProxyClass=org.apache.ojb.broker.core.proxy.SetProxyDefaultImpl CollectionProxyClass=org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl StatementManagerClass=org.apache.ojb.broker.accesslayer.StatementManager StatementsForClassClass=org.apache.ojb.broker.accesslayer.StatementsForClassImpl JdbcAccessClass=org.apache.ojb.broker.accesslayer.JdbcAccessImpl RowReaderDefaultClass=org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl ObjectCacheClass=ObjectCacheOSCacheImpl descriptorBasedCaches=false LockManagerClass=org.apache.ojb.odmg.locking.LockManagerDefaultImpl LockMapClass=org.apache.ojb.odmg.locking.InMemoryLockMapImpl LockTimeout=6 ImplicitLocking=true LockServletUrl=http://127.0.0.1:8080/ojb-lockserver LockAssociations=WRITE OqlCollectionClass=org.apache.ojb.odmg.collections.DListImpl_2 SqlInLimit=200 ImplementationClass=org.apache.ojb.odmg.ImplementationImpl OJBTxManagerClass=org.apache.ojb.odmg.LocalTxManager DListClass=org.apache.ojb.odmg.collections.DListImpl_2 DArrayClass=org.apache.ojb.odmg.collections.DListImpl_2 DMapClass=org.apache.ojb.odmg.collections.DMapImpl DBagClass=org.apache.ojb.odmg.collections.DBagImpl DSetClass=org.apache.ojb.odmg.collections.DSetImpl PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew JTATransactionManagerClass=org.apache.ojb.broker.transaction.tm.JBossTransactionManagerFactory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ojb memory question
That makes sense. Thanks very much for your help. M. On Tue, 8 Feb 2005 11:50:21 +0100, CLARAMONTE Jean-Baptiste <[EMAIL PROTECTED]> wrote: > yes this is default behavior : OJB creates an Identity object for each > instance of your mapped objects. This Identity object is then used as a key > for storing the object in the cache. > ... so yes if two Products have reference to the same Attribut object, OJB > will cache just one instance of this Attribute object > > -Message d'origine- > De: Michael Newton > A: ojb-user@db.apache.org > Date: 07/02/2005 23:02 > Objet: ojb memory question > > I am experiementing with using OJB in an app that has a large dataset, > and will need to cache the whole dataset. > > I am trying to assess the storage requirements of the cache, so I have > a basic question about OJB's internals: > > Say I have objects Product and Attribute. Products have foreign keys > to Attributes. > > If many Products refer to the same Attribute in the database, and I > let OJB cache Products (with Attributes in them), is OJB smart enough > to create and cache just one instance of the Attribute, or will it > create an instance of that Attribute for every Product? > > M. > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > *** We scanned this email for malicious content *** > *** IMPORTANT: Do not open attachments from unrecognized senders *** > *** MailSystem ASTON *** > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ojb memory question
I am experiementing with using OJB in an app that has a large dataset, and will need to cache the whole dataset. I am trying to assess the storage requirements of the cache, so I have a basic question about OJB's internals: Say I have objects Product and Attribute. Products have foreign keys to Attributes. If many Products refer to the same Attribute in the database, and I let OJB cache Products (with Attributes in them), is OJB smart enough to create and cache just one instance of the Attribute, or will it create an instance of that Attribute for every Product? M. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ObjectCache that persists serialized objects to disk.
Has anyone implemented an ObjectCache that serializes the objects and saves them on the filesystem? The goal would be an object cache that persists across runs of the application. Is there an implementation like this out there, or can someone comment on the viability of this idea? thanks M. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]