[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: JPA DAO in Desktop Application

Marc Schlegel schrieb:

> Your advices regarding multiple EMs at the same time are very usefull, I have to
> think more about this before I start coding something. Currently I am trying to
> integrate Spring DM in my RCP, at least in the data-bundle/plugin. Lets see what
> Spring can do when it comes to the lifecycle of a EM instance, I just know there
> is some support for that.

I think Tom is right, it really depends on what you want to do. I also
think that the approach to reuse one singleton instance of the em is not
wrong at all, for example if you have one global save action in your app
(like we have in our project) it is useful to just have one instance of
the em. If this leads to an exception in your case, there may be a
configuration issue.

I would like to give a note about the spring dm thougths. If you use
spring dm to manage the emf and the em, you only have to options (and to
me only one works nice), as the spring-configuration only lets you
decide between singleton and prototype scope of spring beans (there are
more scopes, but there are all only working in the web tier because they
are session related). The latter creates a new instance of a bean every
time which is not really working unless you dont't have long running
transactions. So what I mean to say is, if decide to use spring, the
singleton approach is the easiest way to set things up (I'm not
confident enough to say "the only" unless I feel that way :-))

By the way, we develop a single sourced application that runs both on
desktop an in the web and use the singleton approach (session-singleton
for the web case) and it works like a charm.

As a hint, the use of spring does not necessarily make your life easier,
as the configuration can be tricky, too.

In the end its all about concepts and your specific requirements.

I hope you have fun playing around with those options,

Another Tom