Hello Mike,
Thanks for the reply. I just tryed your solution and it works perfect. I
first had my doubs because TIMESTAMP and DATETIME have different formats
when you look in the database, but mysql seems to accept a TIMESTAMP value
for a DATETIME column. Mysql only loses the milliseconds part of a
TIMESTAMP, but that isn't a problem for me.
As i don't work from source i've wrote my own adapter. I had some problem
to understand why the constructor of JDBCAdapter gets called when using
MySQLAdapter, but that just seems to be happening. As a reference here's my
small adapter:
====================
import org.objectstyle.cayenne.dba.mysql.*;
import org.objectstyle.cayenne.dba.*;
public class CustomMySQLAdapter extends MySQLAdapter{
public CustomMySQLAdapter() {
super();
this.typesHandler =
TypesHandler.getHandler(findAdapterResource("/mytypes.xml"));
}
}
=====================
types.xml should be copied to mytypes.xml and placed in the directory where
the adapter is placed.
I've not yet tested this procedure throughly but i seems to work.
About the modeler:
I had some major problems getting my custom adapter to work with the
modeler. The adapter was in the classpath, the modeler could see it, but
when i entered the adapter classname the field turned red and the blue hint
said "cannot find adapter". I had made a postgresql adapter in the past so
i did know i did nothing wrong with the classpath. After a lot of strugling
i discovered that the constructor of my adapter did throw a exception (i
forgot to include mytypes.xml in the .jar file). Maybe it's a idea to
display a stack trace when a custom adapter could not be found, that way
the user would know "hey modeler can find my adapter, but my adapter throws
a exception which the modeller sees as adapter not found exception".
Cheers,
Twan
At 21:43 14-10-2004, you wrote:
>Twan Kogels <twa..wansoft.com> wrote:
> > Mysql also has a DATETIME type, that's used for date+time values, for
> > example "10-10-2004 10:29". I've looked into the Modeler but could not
>find
> > the DATETIME type for a DBentity. I've found DATE (only used for dates
> > "10-10-2004") and TIME (only used for time "10:29").
> >
> > If you want to use date and time then the only choice seems to TIMESTAMP,
> > but that type has very strange non standard effects in mysql.
> >
> > Does cayenne supports DATETIME type of mysql or is there any other way
> > around the TIMESTAMP problem?
>
>You can change what database types are used for any particular adaptor by
>changing org/objectstyle/cayenne/dba/mysql/types.xml
>
>If you're working with the source, you can just modify the file directly.
>
>If not, you can create your own adaptor subclass that uses your own
>types.xml file, and specify the subclass.
>
> <jdbc-type name="TIMESTAMP">
> <db-type name="DATETIME"/>
> </jdbc-type>
>
>If this works as expected, you might submit a JIRA issue (which should look
>similar to this one for Oracle that changes from DATE to TIMESTAMP.)
>
> http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-71
This archive was generated by hypermail 2.0.0 : Fri Oct 15 2004 - 03:38:30 EDT