I use a very similar arquitechture. I use Hibernate Criteria hidden in
DAOs' implementations. I code my services to DAO interfaces. Changing my
data access layer is just coding different implementations to the same
interfaces.
Richard Wallace wrote:
How do you normally do search functionality like this? Do you expose
the Hibernate query API to the JSF layer?
The main reason I wanted to try and abstract it was in case we did see
some need in the future to swtich to a different ORM tool like EJB 3 or
whatever else is the latest greatest. I mean, in theory, the
presentation layer shouldn't care one wit what the data access layer
uses to get it's job done. That's the whole reason for abstracting the
Hibernate stuff in DAOs.
I don't think my situation is all that different from others that are
out there. I have Hibernate at the lowest level doing data access,
spring in the middle managing services which use the data access layer
and then JSF at the presentation layer utilizing the APIs the services
expose. I guess I'm just curious about what the best practices are and
what people would think if I exposed the fact that the data layer is
using Hibernate at the presentation layer by using the Hibernate
criteria API.
Werner Punz wrote:
Richard Wallace wrote:
Hey all,
I'm just wondering how anyone has implemented like a generic search
using Hibernate as a backend. More specifically, when the data access
layer (Hibernate) is abstracted away from the presentation layer (JSF).
I I'm trying to find some way of creating some kind of search ability
that can have a user defined number and type of parameters. The problem
I'm running into is that the data access library being used is
completely abstracted from JSF so I need some neutral type of criteria
or query to pass to the underlying system.
I've toyed with creating a custom criteria API that can then be
translated into whatever backend criteria API is in use, whether it's
Hibernate, EJB 3 or something else. But it's a complicated issue even
for some of the seemingly simple things that I'm trying to do.
Well abstracting the already abstracted hibernate query api does not
really
make that much sense unless you plan to switch the db access layers.
All I can say is, dont do it and even if you try to do it, it is not
worth
the effort.
But as for crtieria queries, you can go for the Hibernate criteria
queries
to get a dynamic query behavior.
- Re: [OT] Generic search in Hibernate Julián García
-