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:08:07 EDT