Using database views [message #386013] |
Wed, 18 March 2009 13:57  |
Eclipse User |
|
|
|
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 10:23  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03733 seconds