Thanks for your reply.
I tried your suggestion:
HttpSession session = req.getSession();
DataContext context = ServletUtil.getSessionContext(session);
Expression qualifier =
Expression.fromString(some_condition_for_table_A);
SelectQuery select = new SelectQuery(A.class, qualifier);
List<A> mylistA = context.performQuery(select);
...
qualifier = Expression.fromString(some_condition_for_table_C);
select = new SelectQuery(C.class, qualifier);
List<C> grType = context.performQuery(select);
...
I get an exception in the second SelectQuery:
No DataMap found, can't route query
org.apache.cayenne.query.SelectQuer..eb042[root=class
com.tecsidel.db.IdmGroupType,name=<null>]
A and C are invented names to simplify the code.
Any help will be appreciated.
-----Mensaje original-----
De: Michael Gentry [mailto:blacknex..mail.com]
Enviado el: viernes, 09 de mayo de 2008 16:08
Para: use..ayenne.apache.org
Asunto: Re: how can I use two different databases in one web
application?
I suspect you are wanting to access both databases at the same time
and within the same DataContext? If so, try your second option (one
DataDomain, two DataMaps, two DataNodes -- one DataMap assigned to
your Oracle DataNode and the other DataMap assigned to your MySQL
DataNode). Then create a DataContext normally (no parameters).
Cayenne should be able to route to the proper database (through the
DataNode) depending on which classes you are using (defined in the
DataMaps). Just make sure you have totally separate classes (don't
try to reuse the same class in two DataMaps).
Let us know if you have other issues.
/dev/mrg
On Fri, May 9, 2008 at 8:17 AM, Garcia Corral, Josep
<josep.garci..ecsidel.es> wrote:
> Hello,
>
> I am using the last stable version of Cayenne: 2.0.4.
>
>
>
> The situation is:
>
> Database 1: oracle, with tables A, B
>
> Database 2: mysql, with tables C, D, E
>
>
>
> First question is: what's the best way to define this in a Cayenne
> Project?
>
>
>
> First_Domain:
>
> First_DomainMap
>
> First_DomainNode
>
> Second_Domain:
>
> Second_DomainMap
>
> Second_DomainNode
>
>
>
> or:
>
>
>
> Domain:
>
> First_DomainMap
>
> First_DomainNode
>
> Second_DomainMap
>
> Second_DomainNode
>
>
>
> And then, from a servlet, how can I have access to tables from
Database
> 1 and 2? What I have used so far is:
>
>
>
>
>
> I tried this but it did not work:
>
> DataContext.createDataContext("First_Domain");
>
> ...
>
>
>
> This did not work either:
>
> HttpSession session = req.getSession();
>
> DataContext context = ServletUtil.getSessionContext(session);
>
> Expression qualifier = Expression.fromString(some_condition);
>
> SelectQuery select = new SelectQuery(A.class, qualifier);
>
> ...
>
> qualifier = Expression.fromString(other_condition);
>
> select = new SelectQuery(C.class, qualifier);
>
>
>
>
>
> Josep Garcia
>
>
>
>
This archive was generated by hypermail 2.0.0 : Fri May 09 2008 - 10:31:50 EDT