Multiple data sources

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple data sources

Tony Giaccone-2
What's the general technique for using multiple data sources with a cayenne
project?

I want to read from one table, and then use that data to collect data from
a second database, and validate certain values.

Anyone have a specific example of this kind of work?



Tony Giaccone
Reply | Threaded
Open this post in threaded view
|

Re: Multiple data sources

Michael Gentry
Hi Tony,

I've not done this before, but pretty sure you'll need two DataNodes (to
manage the two DB connections, one DB per node) and two DataMaps (one
attached to each DataNode).  Put the relevant Java classes/etc in the
proper DataMap and Cayenne will then handle the routing for you.  (Cayenne
determines which DataNode to use based upon the Java class/package that is
contained in each DataMap.)

BTW, which version of Cayenne are you using?

mrg


On Thu, Dec 7, 2017 at 1:50 PM, Tony Giaccone <[hidden email]> wrote:

> What's the general technique for using multiple data sources with a cayenne
> project?
>
> I want to read from one table, and then use that data to collect data from
> a second database, and validate certain values.
>
> Anyone have a specific example of this kind of work?
>
>
>
> Tony Giaccone
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple data sources

Tony Giaccone-2
MRG,

I'm using the most recent version of Cayenne. My question is more about how you instantiate the two data stacks in the application. Do they belong in separate data models? Or two nodes in the same model?  Do you run two separate cayenne stacks, with different contexts?

But with your answer I think I understand how to get started.


Tony

On 2017-12-07 14:36, Michael Gentry <[hidden email]> wrote:

> Hi Tony,
>
> I've not done this before, but pretty sure you'll need two DataNodes (to
> manage the two DB connections, one DB per node) and two DataMaps (one
> attached to each DataNode).  Put the relevant Java classes/etc in the
> proper DataMap and Cayenne will then handle the routing for you.  (Cayenne
> determines which DataNode to use based upon the Java class/package that is
> contained in each DataMap.)
>
> BTW, which version of Cayenne are you using?
>
> mrg
>
>
> On Thu, Dec 7, 2017 at 1:50 PM, Tony Giaccone <[hidden email]> wrote:
>
> > What's the general technique for using multiple data sources with a cayenne
> > project?
> >
> > I want to read from one table, and then use that data to collect data from
> > a second database, and validate certain values.
> >
> > Anyone have a specific example of this kind of work?
> >
> >
> >
> > Tony Giaccone
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple data sources

Michael Gentry
Hey Tony,

"Do they belong in separate data models?"

Belong?  No.  You could use two separate models, but it is likely easier to
use one model depending upon your requirements.


"Or two nodes in the same model?"

You can have multiple data nodes and data maps in the same model.  Each
data map would point to a different data node.  That's how Cayenne figures
out the routing, by having your entities associated with a given data map
which is assigned to a given data node.


"Do you run two separate cayenne stacks, with different contexts?"

Again, you could, but likely is easier to use just one.  A single data
context can handle multiple data nodes and data maps.


mrg


On Tue, Dec 12, 2017 at 10:45 AM, [hidden email] <[hidden email]>
wrote:

> MRG,
>
> I'm using the most recent version of Cayenne. My question is more about
> how you instantiate the two data stacks in the application. Do they belong
> in separate data models? Or two nodes in the same model?  Do you run two
> separate cayenne stacks, with different contexts?
>
> But with your answer I think I understand how to get started.
>
>
> Tony
>
> On 2017-12-07 14:36, Michael Gentry <[hidden email]> wrote:
> > Hi Tony,
> >
> > I've not done this before, but pretty sure you'll need two DataNodes (to
> > manage the two DB connections, one DB per node) and two DataMaps (one
> > attached to each DataNode).  Put the relevant Java classes/etc in the
> > proper DataMap and Cayenne will then handle the routing for you.
> (Cayenne
> > determines which DataNode to use based upon the Java class/package that
> is
> > contained in each DataMap.)
> >
> > BTW, which version of Cayenne are you using?
> >
> > mrg
> >
> >
> > On Thu, Dec 7, 2017 at 1:50 PM, Tony Giaccone <[hidden email]> wrote:
> >
> > > What's the general technique for using multiple data sources with a
> cayenne
> > > project?
> > >
> > > I want to read from one table, and then use that data to collect data
> from
> > > a second database, and validate certain values.
> > >
> > > Anyone have a specific example of this kind of work?
> > >
> > >
> > >
> > > Tony Giaccone
> > >
> >
>