frankshu2015 / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
0 stars 0 forks source link

More extensible HibernateSearchFacade and HibernateSearchProcessor #64

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have used v 0.5.0 and 0.5.1 and in both cases, I had a need to alter some 
internal functionality (specifically alter the Query object used) and the core 
classes weren't extensible enough to promote reuse.

Attached is a patch that promotes a higher level of extensibility.  

Original issue reported on code.google.com by chuckdea...@gmail.com on 7 Jun 2010 at 7:33

Attachments:

GoogleCodeExporter commented 9 years ago
Issue #50 would be fixed by this patch as well.

Original comment by chuckdea...@gmail.com on 7 Jun 2010 at 7:33

GoogleCodeExporter commented 9 years ago
Issue #63 would benefit from this patch.  This is exactly the use case we are 
solving.  In our case, we subclass both the SearchFacade and the 
SearchProcessor.  The searchFacade overrides newProcessor() to return a 
subclass of HibernateSearchProcessor that overrides the createQueryMethod.  It 
is in that method that you can add the setCachable(true) statement.

In my environment, we actually have a handler object that gets passed to the 
facade so that we won't have to subclass it for every variation, we just 
instantiate the Facade with the correct handler.

Original comment by chuckdea...@gmail.com on 7 Jun 2010 at 7:45

GoogleCodeExporter commented 9 years ago
I liked the patch, i'd just use a WeakHashMap instead the HashMap to take care 
of references.

Original comment by terciofi...@gmail.com on 13 Nov 2010 at 2:59

GoogleCodeExporter commented 9 years ago
I've seen several people asking for this now.

Original comment by dwolvert on 13 Nov 2010 at 3:22

GoogleCodeExporter commented 9 years ago

Original comment by dwolvert on 27 Feb 2011 at 10:55

GoogleCodeExporter commented 9 years ago

Original comment by dwolvert on 2 Oct 2011 at 12:03

GoogleCodeExporter commented 9 years ago
Can somebody apply the patch?

Original comment by decebal....@gmail.com on 20 Dec 2011 at 12:06

GoogleCodeExporter commented 9 years ago

Original comment by dwolvert on 15 Feb 2013 at 1:56

GoogleCodeExporter commented 9 years ago
With the patch provided, HibernateBaseDAO does not work, as it calls 
HibernateSearchProcessor.getInstanceForSessionFactory in setSessionFactory(). 
Should I create a HibernateSearchFacade there in setSessionFactory()? or 
declare as a variable and create in the constructor?.

Original comment by pablit...@gmail.com on 9 Jul 2014 at 10:29

GoogleCodeExporter commented 9 years ago
When I first wrote this whole thing, I optimized for minimal configuration 
rather than flexibility. Some minor architectural changes will need to be made 
to make it more configurable. I think the provided patch is probably the right 
direction, but as pablitohh noted, may not be complete.

I think an option might be to look at the JPA version of all this code at 
search/src/main/java/com/googlecode/genericdao/search/jpa. The pattern there 
requires searchprocessor to be injected explicitly into the search facade and 
the dao (see dao/src/main/java/com/googlecode/genericdao/dao/jpa).

Original comment by dwolvert on 27 Jul 2014 at 10:14

GoogleCodeExporter commented 9 years ago
A documentation update will be required as well, because the framework will 
require more configuration to set up. You update the same project 
"hibernate-maven-web" to work with the new configuration.

Alternatively, you may find a way to allow the framework to continue to 
auto-configure itself if explicit config is not available.

Original comment by dwolvert on 27 Jul 2014 at 10:23