Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Using database views
Using database views [message #386013] Wed, 18 March 2009 17:57 Go to next message
Elvis Dominguez is currently offline Elvis Dominguez
Messages: 52
Registered: July 2009
Location: Switzerland
Member
Hi all,

sorry for the maybe obvious response to this question, and sorry for my
bad English.

Hi have a project (DB <--> JBoss <--> RCP), with let's say, 4 domain
objects and relative daos.
@Entity Customer
@Entity Article (FK to Store)
@Entity Store
@Entity AuthorizedArticles (FK to Customer and Articles, plus other
fields)

Now I would like to display in a TableViewer Articles loaded from
AuthorizedArticles table. Let's say a table containing Article.code,
Article.description and Article.defaultStore.description.

To display such data in a TableViewer the JPA/db 's load is very high due
to joins, lazy loading and whatever (= slow performances)
Now, to avoid such load and bad performances I had the idea to create a
DATABASE VIEW, let's say AuthArticlesView, containing my 3 display fields.
I have created an @Entity and bind to this VIEW.
The performances increase was absolutely a joy (load time on the client
from 700 ms to 30 ms).

But now I would like to know what are the consequences of this «trick» or
better said «dirty approach».
Or better understand what is the correct approach.
Maybe native query with SqlResultSetMapping? over table or view?
Examples? (i can't foind a decent one on the net)
Isn't there a native support to views? Why?


I have tried implementing DTO but the performances aren't much better as
the original try.

Hope someone can clarify my doubts... Thanks!
Kindly

--
Elvis Dominguez
Re: Using database views [message #386043 is a reply to message #386013] Thu, 19 March 2009 14:23 Go to previous message
Gordon Yorke is currently offline Gordon Yorke
Messages: 77
Registered: July 2009
Member
This approach is fine. You should be aware that there is a separate cache
for this view Entity and you should either not use a shared cache for this
Entity or if possible the better approach would be to "invalidate" the
corresponding data in the shared cache when one of the underlying Entities
changes.

If you are also writing through this view and use version locking for
multiple underlying Entities you will have to use the
"FieldsLockingPolicy" and increment your version values manually on write.

As an alternative to the view have you tried using fetch joins to load all
the data at once? EclipseLink supports nested fetch joins through the
query hint "eclipselink.join-fetch"
--Gordon
Previous Topic:It is possible that I can use one entity for some tables?
Next Topic:EclipseLink 1.1.0
Goto Forum:
  


Current Time: Sun Oct 26 00:23:46 GMT 2014

Powered by FUDForum. Page generated in 0.03227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software