Home » Eclipse Projects » EclipseLink » desktop Swing application with EclipseLink
desktop Swing application with EclipseLink [message #727803] |
Thu, 22 September 2011 01:12 |
Marc Messages: 25 Registered: July 2009 |
Junior Member |
|
|
I've started learning jpa and EclipseLink only few days ago, and till now i've succeeded to understand the basics of the API, but still don't feel able to build a serious application that can stand for long.
The problem is that i didn't find any articles that gives enough informations about some good practices/design patterns, that match the kind of applications i'm trying to build. I've found some articles talking about jpa in standalone applications, but still were dealing with clients and servers and using sessions, something that confuses me.
So just to make my self clear, the application i'm about to develop doesn't need any client or server or any kind of network communication, it's a mono-user Swing application, on which i intend to use EclipseLink with the Derby Embedded database. The application isn't a small one, it will have to deal with roughly 30 entities ...
I was thinking about creating one EntityManager at the start of the application, and to perform all my transactions through it until the application shutdowns, but after some researchs i figured out that such a solution may have performance issues ... creating an EntityManager and closing it on each transaction doesn't seem to be a good idea neither.
I need some indications that can put me in the right way, so any kind of help (tips, links ...) will be very appreciated.
Thanks
|
|
|
Re: desktop Swing application with EclipseLink [message #727861 is a reply to message #727803] |
Thu, 22 September 2011 05:22 |
Tom Eugelink Messages: 825 Registered: July 2009 |
Senior Member |
|
|
I've written a fairly large Swing application (40 concurrent users, 100 entities) on top of an Informix database. The biggest thing with entity manager here, is how to user expects the application to behaves. I found that one EM per window (JFrame) is the most logical setup. (And one EntityManagerFactor per application.)
This means that you load entities once for each window. Modifications stay withing the window until they are saved.
Because you have multiple EMF's, you need to disable the second level cache.
Tom
On 2011-09-22 03:12, Marc wrote:
> I've started learning jpa and EclipseLink only few days ago, and till now i've succeeded to understand the basics of the API, but still don't feel able to build a serious application that can stand for long.
>
> The problem is that i didn't find any articles that gives enough informations about some good practices/design patterns, that match the kind of applications i'm trying to build. I've found some articles talking about jpa in standalone applications, but still were dealing with clients and servers and using sessions, something that confuses me.
>
> So just to make my self clear, the application i'm about to develop doesn't need any client or server or any kind of network communication, it's a mono-user Swing application, on which i intend to use EclipseLink with the Derby Embedded database. The application isn't a small one, it will have to deal with roughly 30 entities ...
>
> I was thinking about creating one EntityManager at the start of the application, and to perform all my transactions through it until the application shutdowns, but after some researchs i figured out that such a solution may have performance issues ... creating an EntityManager and closing it on each transaction doesn't seem to be a good idea neither.
>
> I need some indications that can put me in the right way, so any kind of help (tips, links ...) will be very appreciated.
>
> Thanks
|
|
| | | | | | | | | | |
Re: (no subject) [message #728275 is a reply to message #728176] |
Thu, 22 September 2011 21:04 |
Marc Messages: 12 Registered: September 2011 |
Junior Member |
|
|
One more question: I'm using eclipse indigo for EE developement, just to take benefit from the JPA project support. I created a JPA project and in the persistence.xml file i set <property name="eclipselink.cache.shared.default" value="false"/>, a warning appears :
"eclipselink.cache.shared.default" is a legacy entity caching property. Consider migration to JPA 2.0 and EclipseLink cache settings via annotation or XML.mapping file
I'm using the last release of eclipseLink (2.3.0), and here's a link to EclipseLink wiki, where there's an example for setting the property onto the persistence.xml file, so what's wrong? what could be the reason of the warning?
Note that i used the same property in a normal java project, and there were no warnings, it appeared only when used the JPA project.
[Updated on: Thu, 22 September 2011 21:22] Report message to a moderator
|
|
| |
Re: desktop Swing application with EclipseLink [message #728349 is a reply to message #728175] |
Fri, 23 September 2011 04:48 |
Tom Eugelink Messages: 825 Registered: July 2009 |
Senior Member |
|
|
> @Gordon Thanks for the contribution
> Quote:
>> In a networked environment if the application would benefit from caching to alleviate demand on the database cache co-ordination is still an option with a desktop application, although you may need to consider total network traffic. (ie co-ordinate more static data but use @Cacheable false for volatile data.)
>
> I didn't understand much of this, could you explain more please. Knowing that i have no network traffic, do you think i should take more time to learn about coordination before starting to code?
Cache co-ordination are ways to still use the cache by, for example, only allowing certain low frequently modified entities to be cached. This requires not blunt usage of the cache, but coordinated use. A more advanced approach would be distributed caching, where caches are synced between Swing clients separately from the database. A interesting intermediate step would be to purge the cache in every client of all copies of an entity, if one client commits a change to that entity. Does Eclipselink have support for this, Gordon?
Tom
|
|
| | |
Re: (no subject) [message #729021 is a reply to message #728488] |
Sat, 24 September 2011 19:03 |
Marc Messages: 12 Registered: September 2011 |
Junior Member |
|
|
Quote:I'm using the last release of eclipseLink (2.3.0), and here's a link to EclipseLink wiki, where there's an example for setting the property onto the persistence.xml file, so what's wrong? what could be the reason of the warning?
The warning is due to that JPA 2.0 requires to set <shared-cache-mode> element to NONE under the persistence-unit element (instead of "eclipselink.cache.shared.default" property), hope this will help somebody.
However I noticed that disabling 2nd-Level caching leads to another warning if I try to set other caching properties (such as "eclipselink.cache.size.default" property) ==> Does this mean that all caching properties are affecting only 2nd-Level cache? Same question concerning @Cache and @Cacheable annotations?
[Updated on: Sat, 24 September 2011 20:57] Report message to a moderator
|
|
| | | |
Goto Forum:
Current Time: Wed Sep 25 06:42:41 GMT 2024
Powered by FUDForum. Page generated in 0.06868 seconds
|