cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut Bolčina <borut.bolc...@gmail.com>
Subject Merging Configuration from Multiple Deployment Units
Date Fri, 12 Feb 2010 11:57:30 GMT
Hello,

I have two projects (jars) - each is only having Cayenne Data Objects for
two different models/two different databases.

project-model1:
├───java
│   └───si
│       └───planet9
│           └───logotypes
│               └───model
│                   │   Logo.java
│                   └───auto
│                           _Logo.java
│
└───resources
        cayenne.xml
        LogotypesMap.map.xml

project-model2:
├───java
│   ├───com
│   │   └───interseek
│   │       └───startpage
│   │           └───model
│   │               │   Fund.java
│   │               └───auto
│   │                       _Fund.java
└───resources
        cayenne.xml
        StartpageMap.map.xml


Some of my web apps need project-model1, some project-model2 and some could
use both.

cayenne.xml for project-model1:

<?xml version="1.0" encoding="utf-8"?>
<domains project-version="3.0.0.1">
<domain name="InterseekDomain">
    <map name="LogotypesMap" location="LogotypesMap.map.xml"/>

    <node name="LogotypesNode"
         datasource="dbcp-logotypes.properties"
         factory="org.apache.cayenne.conf.DBCPDataSourceFactory">
            <map-ref name="LogotypesMap"/>
     </node>
</domain>
</domains>

and for project-model2:

<?xml version="1.0" encoding="utf-8"?>
<domains project-version="3.0.0.1">
<domain name="InterseekDomain">
    <map name="StartpageMap" location="StartpageMap.map.xml"/>

    <node name="StartpageNode"
         datasource="dbcp.properties"
         factory="org.apache.cayenne.conf.DBCPDataSourceFactory">
            <map-ref name="StartpageMap"/>
     </node>
</domain>
</domains>

I was hoping the two domains will get merged and so both datamaps will get
loaded.

The Logo data object is from LogotypesNode and the Fund data object is from
StartpageNode. The code

        ObjectContext context = DataContext.createDataContext();

        SelectQuery q = new SelectQuery(Logo.class);
        List<Logo> logos = context.performQuery(q);

        for (Logo logo : logos) {
            logger.info(logo);
        }

        q = new SelectQuery(Fund.class);
        List<Fund> funds = context.performQuery(q);

        for (Fund fund : funds) {
            logger.info(fund);
        }


prints out:

DEBUG [12:33:00.020] using domain file name: cayenne.xml
DEBUG [12:33:00.021] initialize starting.
 INFO [12:33:00.030] started configuration loading.
 INFO [12:33:00.032] loaded domain: InterseekDomain
 INFO [12:33:00.083] loaded <map name='LogotypesMap'
location='LogotypesMap.map.xml'>.
 INFO [12:33:00.085] loading <node name='LogotypesNode'
datasource='dbcp-logotypes.properties'
factory='org.apache.cayenne.conf.DBCPDataSourceFactory'
schema-update-strategy='org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy'>.
 INFO [12:33:00.092] using factory:
org.apache.cayenne.conf.DBCPDataSourceFactory
DEBUG [12:33:00.093] DBCP Properties: {cayenne.dbcp.validationQuery="SELECT
1 FROM AUTO_PK_SUPPORT;", cayenne.dbcp.url=jdbc:mysql://
dev.interseek.com:3306/logotypes?characterEncoding=utf8&amp;autoReconnect=true,
cayenne.dbcp.maxActive=50, cayenne.dbcp.maxIdle=8,
cayenne.dbcp.password=masterkey, cayenne.dbcp.maxWait=10000,
cayenne.dbcp.minIdle=5, cayenne.dbcp.driverClassName=com.mysql.jdbc.Driver,
cayenne.dbcp.username=backend}
 INFO [12:33:00.109] loaded datasource.
 INFO [12:33:00.110] no adapter set, using automatic adapter.
 INFO [12:33:00.118] loaded map-ref: LogotypesMap.
DEBUG [12:33:00.119] added domain: InterseekDomain
 INFO [12:33:00.119] finished configuration loading in 89 ms.
DEBUG [12:33:00.119] initialize finished.
 INFO [12:33:00.200] --- will run 1 query.
 INFO [12:33:00.376] --- transaction started.
DEBUG [12:33:00.386] searching for resource under:
org/apache/cayenne/dba/mysql/types.xml
 INFO [12:33:00.405] Detected and installed adapter:
org.apache.cayenne.dba.mysql.MySQLAdapter
 INFO [12:33:00.436] SELECT t0.url_firma, t0.url_image, t0.url_hash_image,
t0.url_tis, t0.url_bizi, t0.url, t0.id FROM logo t0 - prepared in 24 ms.
 INFO [12:33:00.453] === returned 0 rows. - took 42 ms.
 INFO [12:33:00.454] +++ transaction committed.
ERROR [12:33:00.459] Job reader.gold-logotypes threw an unhandled Exception:

org.apache.cayenne.CayenneRuntimeException: [v.3.0RC1 Jan 05 2010 14:44:59]
No DataMap found, can't route query
org.apache.cayenne.query.SelectQuery@1e881b6[root=class
com.interseek.startpage.model.Fund,name=<null>]
    at org.apache.cayenne.query.AbstractQuery.route(AbstractQuery.java:134)



I am using Cayenne 3.0RC1.


What is the easiest way of doing this? I was reading
http://cwiki.apache.org/CAY/runtime-metadata-merging.html, but am I doing
something wrong?


Thanks,
Borut

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message