Re: unit testing Cayenne objects

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed May 04 2005 - 17:03:30 EDT

  • Next message: Andrus Adamchik: "Re: unit testing Cayenne objects"

    Erik,

    > My next question is about configuration and how to do some of it
    > through the API. I want to use a file-based cayenne.xml and .map.xml
    > file, but I want to configure JDBC URL through the API rather than
    > through a .driver.xml file.

    I am too lazy to put it on Wiki, so I have to answer this question every
    once in a while... The general approach is to

    1. Map a DataNode with arbitrary (possibly invalid) driver info.
    2. On startup after you load configuration but before you access Cayenne,
    get down the stack to the DataNode (Configuration -> DataDomain ->
    DataNode) and set your own DataSource on a DataNode by calling
    "DataNode.setDataSource(DataSource)".
    3. You can use any implementation of a DataSource. For instance Cayenne
    PoolManager for pooled DataSource. Or DriverDataSource for a simple one:

    http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/conn/PoolManager.html
    http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/conn/DriverDataSource.html

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed May 04 2005 - 17:03:32 EDT