Hi Gus,
Could you have a go at the latest betwixt build (just committed a fix to
cvs, which sounds a bit similar to your situation). If that is still not
working, it would be nice to have a testcase of some kind to make my
life a bit easier (don't know if commons-sql moved to db commons,
although it doesn't seem like it ?)
I'll keep ojb-user on the cc, if that's ok (please keep commons-dev on
the cc too,since I am not subscribed to ojb-user..
Mvgr,
Martin
On Fri, 2003-11-21 at 23:46, Gus Heck wrote:
> In light of this, I decided to enable further development by setting the
> missing username and password for now until the bug can be resolved.
> When I did I got more funny results that look very much like a bug...
> The following code:
>
> InputStream is =
> Thread.currentThread().getContextClassLoader().getResourceAsStream("project_schema.xml");
> Database db = null;
> try {
> DatabaseReader reader = new DatabaseReader();
> db = (Database) reader.parse( is );
> } catch (IntrospectionException ie) {
> throw new RuntimeException("Error creating DatabaseReader
> for project_schema.xml");
> } catch (IOException ioe ) {
> throw new RuntimeException("Error loading project_schema.xml");
> } catch (SAXException saxe ) {
> throw new RuntimeException("Error parsing project_schema.xml");
> }
>
> System.out.println(db);
> for (Iterator iter = db.getTables().iterator();iter.hasNext();) {
> org.apache.commons.sql.model.Table t
> = (org.apache.commons.sql.model.Table) iter.next();
> System.out.println(t);
> System.out.println(t.getName());
> }
>
> produces the following output:
>
> [EMAIL PROTECTED];tableCount=1]
> [EMAIL PROTECTED]
> null
>
> The number of tables is correct, but I feel certain that it should not
> be named null giventhe following project_schema.xml (still in defaults
> for the field sizes... I'll deal with that after I write something to
> the database successfully):
>
> <database name="fdbtest2">
> <table name="LocationBase">
> <column name="id"
> javaName="id"
> type="INTEGER"
> primaryKey="true"
> required="true"
> />
> <column name="country"
> javaName="country"
> type="VARCHAR"
> size="24"
> />
> <column name="stateOrRegion"
> javaName="stateOrRegion"
> type="VARCHAR"
> size="24"
> />
> <column name="subRegion"
> javaName="subRegion"
> type="VARCHAR"
> size="24"
> />
> <column name="city"
> javaName="city"
> type="VARCHAR"
> size="24"
> />
> </table>
> </database>
>
> Sadly it appears that commons-sql's DatabaseReader is just a fairly
> simple extension of a betwixt BeanReader...
>
> package org.apache.commons.sql.io;
>
> import java.beans.IntrospectionException;
>
> import org.apache.commons.betwixt.XMLIntrospector;
> import org.apache.commons.betwixt.io.BeanReader;
> import org.apache.commons.betwixt.strategy.HyphenatedNameMapper;
> import org.apache.commons.sql.model.Database;
>
> /**
> * This class parsers XML and creates a fully populated Database bean.
> * This class is-a Digester and so can support configuration via custom
> rules.
> *
> * @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
> * @version $Revision: 1.14 $
> */
> public class DatabaseReader extends BeanReader {
>
> public DatabaseReader() throws IntrospectionException {
> setXMLIntrospector( newXMLIntrospector() );
> registerBeanClass(Database.class);
> }
>
> /**
> * A factory method to create the default introspector used to turn
> * the Database object model into XML
> */
> protected static XMLIntrospector newXMLIntrospector() {
> XMLIntrospector introspector = new XMLIntrospector();
>
> // configure the style of the XML, to brief and attribute based
> introspector.setAttributesForPrimitives(true);
> introspector.setWrapCollectionsInElement(false);
>
> // set the mixed case name mapper
> introspector.setElementNameMapper(new HyphenatedNameMapper());
> //introspector.setElementNameMapper(new DecapitalizeNameMapper());
>
> return introspector;
> }
> }
>
>
> and so this is probably a betwixt bug. I hope someone who understands
> betwixt can verify this.... (hence the cross post to commons-dev).
>
> -Gus
>
>
>
> Andy Malakov wrote:
>
> >Hello All,
> >
> >It looks like a bug:
> >
> >Class o.a.ojb.broker.metadata.MetadataManager.copyOfGlobalRepository() uses
> >SerializationUtils.clone() to return a copy of OJB
> >repository. At the same time some objects in repository graph have transient fields
> >which become un-initialized (null) after the
> >clone.
> >
> >For example, o.a.ojb.broker.metadata.fieldaccess.AnonymousPersistentField has
> >fkCache map that will become null in clone, and will
> >cause NullPointerException when get()/set() will be executed.
> >
> >Method copyOfGlobalRepository() is required for per-thread handling of metadata.
> >
> >Thank you,
> >Andy
> >
> >
> >---------------------------------------------------------------------
> >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]
--
Martin van den Bemt <[EMAIL PROTECTED]>
mvdb.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]