|Using database views [message #386013]
||Wed, 18 March 2009 13:57
|| Elvis Dominguez
Registered: July 2009
sorry for the maybe obvious response to this question, and sorry for my
Hi have a project (DB <--> JBoss <--> RCP), with let's say, 4 domain
objects and relative daos.
@Entity Article (FK to Store)
@Entity AuthorizedArticles (FK to Customer and Articles, plus other
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!
|Re: Using database views [message #386043 is a reply to message #386013]
||Thu, 19 March 2009 10:23
| Gordon Yorke
Registered: July 2009
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
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"
Powered by FUDForum
. Page generated in 0.01873 seconds