[Objectbridge-developers] A few problems
Brought to you by:
thma
From: Kief M. <ki...@ki...> - 2001-07-30 08:26:43
|
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. 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. Thanks, Kief |