Re: [Objectbridge-developers] A few problems
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2001-08-06 14:00:06
|
Hi Kief, Kief Morris wrote: > > Howdy, I've been banging on some code, and so far ojb is pretty cool, > but I've run into a few things. > > 1) Dates: I had some issues storing fields of type java.util.Date, which > may or may not be specific to the mySQL JDBC driver. I notice the > example application doesn't use and date/time fields, has this been > tested much with other drivers? > > The issue is that ojb uses PreparedStatement.setObject(int parameterIndex, Object x) > to store fields, and the mySQL driver at least doesn't automatically figure > out what type this is: the result is it stores 0 as the date/time value. > Using setObject(index, myDate, java.sql.Types.TIMESTAMP) works, > as does wrapping the Date object with java.sql.Timestamp, which is > the workaround I've used in my code. > We have similar problems with other drivers too! The Oracle driver for example returns all Number columns as BigDecimal even if the Objects attribute is only a int. We will have to improve this behaviour! For the time being you might work with a ConversionStrategy that makes an explicit TypeConversion before reading and writing from JDBC ResultSets. See the tutorial on this topic: http://objectbridge.sourceforge.net/conversions.html > 2) ObjectCache doesn't appear to retrieve referenced objects. When I > store and then retrieve an object which references a collection, the > retrieved object doesn't have the collection items. If I insert: > > ojb.broker.accesslayer.ObjectCache.getInstance().clear(); > > - between the store and the find, the retrieved object *does* have > the collection. I don't totally understand this - presumably the cache > should return the same object, including its references, but a comparison > of the two objects without the above call shows one has the collection, > the other's collection is empty. > You are right, store does not cache the object. That's why a different object reference is returned by getObjectByQuery(...) There was no special reason for this, but I guess I will change it, because the semantics is really a bit funny due to this asymmetry... I have no idea why your Collection is not filled. This is a thing that MUST work! You might send me your source code (only the relevant stuff) and your repository.xml file to check what's wrong. regards, Thomas > Thanks, > Kief > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers |