Re: SpringBoot and Cayenne

John Huss <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAOUwSGtHL6OEK4is8OQ2rqbX0vgS7VKrANMD8KKZOpt8umWOPA@mail.gmail.com>
Unless you have special needs, yes, there should only be one.

On Mon, Aug 10, 2020 at 1:51 PM Tony Giaccone <[email protected]> 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.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.