db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Jenkins <m...@adamjenkins.net>
Subject Re: 1.1 best practice question - bug?
Date Sun, 03 Jul 2005 19:40:10 GMT
Hi Tom,

Thanks for that example.  I changed my code to almost exactly what you
have below and, while I got my unit tests to pass, I did experience some
odd behaviour.  The example you gave only seems to work if I have a
jdbc-connection-descriptor declared in repository.xml with the same
alias as the PBKey.  If I ommit the jdbc-connection-descriptor or give
it a different name, I get the npe discussed in previous posts (pasted
below for convenience).  This is reproducable and was using the latest
from cvs.  Just thought I'd let you know in case it's a bug.  Let me
know if you need more information.

Cheers
Adam

---paste---


null
java.lang.NullPointerException
        at
org.apache.ojb.broker.core.configuration.ComponentContainerBase.getAllTypes(Unknown Source)
        at
org.apache.ojb.broker.core.configuration.ComponentContainerBase.setSingletonInstance(Unknown
Source)
        at org.apache.ojb.broker.PersistenceConfiguration.<init>(Unknown
Source)
        at
org.apache.ojb.broker.OJB.createPersistenceConfiguration(Unknown Source)
        at org.apache.ojb.broker.OJB.getConfiguration(Unknown Source)
        at org.apache.ojb.broker.OJB.lookupBroker(Unknown Source)

---paste---
On Sun, 2005-07-03 at 12:23 +0200, Thomas Dudziak wrote:
> As I said, you should use the OJB class as an object. Something like
> this should work:
> 
>         OJB                      ojb = new OJB();
>         PBKey                    key = new PBKey("default");
>         JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
> 
>         jcd.setDefaultConnection(false);
>         jcd.setJcdAlias(key.getAlias());
>         jcd.setDbms("postgresql");
>         jcd.setJdbcLevel(3.0);
>         jcd.setDriver("org.postgresql.Driver");
>         jcd.setProtocol("jdbc");
>         jcd.setSubProtocol("postgresql");
>         jcd.setDbAlias("test");
> 
>         DescriptorRepository               model  =
> ojb.getMetadataManager().readDescriptorRepository(new
> FileInputStream("repository.xml"));
>         PersistenceConfigurationDescriptor newPCD = new
> PersistenceConfigurationDescriptor(key, model, jcd);
> 
>         ojb.getMetadataManager().addPersistenceConfiguration(newPCD);
> 
>         PersistenceConfiguration conf   = ojb.getConfiguration(key);
>         PersistenceBroker        broker = conf.createPersistenceBroker();
> 
> 
> Note that it is no longer necessary to store the jcd manually in the
> connectionRepository because this is only maintained for backwards
> compatibility.
> 
> Tom
> 
> ---------------------------------------------------------------------
> 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-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message