Setting ObjectCacheDescriptor programatically

"Steve Vangasse" <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <001401c6bc64$42e08640$0600a8c0@STEVEWORK>
I'm having trouble setting up a JdbcConnectionDescriptor programatically. 
I'm adding a ConnectionPoolDescriptor, SequenceDescriptor and an 
ObjectCacheDescriptor to the JdbcConnectionDescriptor but the 
ObjectCacheDescriptor doesn't appear when I call 
JdbcConnectionDescriptor.toXML() and doesn't have any effect when the 
application is running. Here is my code:

********

JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
jcd.setJcdAlias("mainConnection");
jcd.setDatasourceName("java:comp/env/jdbc/mainConnection");
jcd.setDbms("MySQL");
jcd.setJdbcLevel(3.0);
jcd.setBatchMode(false);
jcd.setUseAutoCommit(1);
jcd.setIgnoreAutoCommitExceptions(false);

ObjectCacheDescriptor ocd = new 
ObjectCacheDescriptor(ObjectCacheTwoLevelImpl.class);
ocd.addAttribute("applicationCache", 
"org.apache.ojb.broker.cache.ObjectCacheDefaultImpl");
ocd.addAttribute("copyStrategy", 
"org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl$CopyStrategyImpl");
ocd.addAttribute("timeout", "900");
ocd.addAttribute("autoSync", "true");
ocd.addAttribute("cachingKeyType", "1");
ocd.addAttribute("useSoftReferences", "true");
log.debug(ocd.toXML());

ConnectionPoolDescriptor cpd = new ConnectionPoolDescriptor();
cpd.setLogAbandoned(true);
cpd.setValidationQuery("SELECT 1");

jcd.setConnectionPoolDescriptor(cpd);
jcd.setObjectCacheDescriptor(ocd);
jcd.setSequenceDescriptor(new SequenceDescriptor(jcd, 
SequenceManagerNativeImpl.class));
connectionRepository.addDescriptor(jcd);

log.debug(jcd.toXML());
*********

I can't use an XML file for reasons I won't go into here. Can anyone see 
what I might be doing wrong here? Has anyone else attempted to do this? Any 
help would be much appreciated.

Thanks,

Steve Vangasse

Boardshop.co.uk - Board Sports Equipment and Clothing for the UK and Europe
www.boardshop.co.uk
0870 0600 688
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.