You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Tony Giaccone <to...@giaccone.org> on 2020/08/10 18:50:55 UTC

SpringBoot and Cayenne

So I'm using the example that was posted here a while ago, and I've
modified it to read from a springboot yml file. I noticed that when the
application spins up, each time a new instance of the CayenneService gets
created, the code to spin up the cayenne runtime gets called.

I have a strong feeling that's not the right behavior.  So I've moved the
runtime to a class side property and then see if it's null before
spinning up the runtime. That seems to work.

My question is, in a well behaved Cayenne based application connected to
only one instance of a database, should there only be one instance of the
runtime, and one instance of the datasource?

Also the code has a shared context, which gets overridden each time the
init method is called.  That doesn't seem like a good idea either.

Re: SpringBoot and Cayenne

Posted by John Huss <jo...@gmail.com>.
Unless you have special needs, yes, there should only be one.

On Mon, Aug 10, 2020 at 1:51 PM Tony Giaccone <to...@giaccone.org> wrote:

> So I'm using the example that was posted here a while ago, and I've
> modified it to read from a springboot yml file. I noticed that when the
> application spins up, each time a new instance of the CayenneService gets
> created, the code to spin up the cayenne runtime gets called.
>
> I have a strong feeling that's not the right behavior.  So I've moved the
> runtime to a class side property and then see if it's null before
> spinning up the runtime. That seems to work.
>
> My question is, in a well behaved Cayenne based application connected to
> only one instance of a database, should there only be one instance of the
> runtime, and one instance of the datasource?
>
> Also the code has a shared context, which gets overridden each time the
> init method is called.  That doesn't seem like a good idea either.
>