Hi Tim,

unfortuantely I cannot really help you with Spring as I am not using it, but I 
have developed many web applications with Empire-db with various frontend 
frameworks like Struts2 and JSF and I have experience with JPA and Hibernate.

All I can say that the approach is different and they cannot easily be 
exchanged.
Instead of a PersistenceManger / entity bean combination in Empire-db I use 
classes derived from DBRecord.
They essentially represent your business objects and should hold all the 
business logic (for a single record).

As far a connection management is concerned I always use a request based 
approach, i.e. a connection is taken from a connection pool the first time it 
is required for a request, then stored on request scope and automatically 
released at the end of the request. You can also use a ThreadLocal to hold your 
connection.
I never store a connection anywhere else but I locally retrieve it from my 
request or context whenever I need it.

Concerning "paged" retrieval there are two methods on DBCommand "skipRows" and 
"limitRows".
Unfortunately those methods are not yet implemented for all database drivers 
and in some cases you will get a NotSupportedException.
Currently I have plans for properly implementing it for Oracle (in the class 
DBCommandOracle).
Feel free to implement it yourself and prossibly contribute your solution.

As the approaches differ between JPA and Empre-DB, you will probably have to 
develop your own patterns.
If you come up with something fancy your welcome to contibute your code 
possibly in a new example app.

I am not sure whether my comments where any useful at all, but I tried.
Regards

Rainer



> from: Tim Colson [mailto:[email protected]]
> to: [email protected]
> re: Advice for multi-DAO, nested objects, connection mgt, Spring config,
> for Click webapp
> 
> Hi!
> 
> The team I'm working with has been experimenting with Empire DB in a small
> Apache Click webapp for managing a Confluence wiki.
> Our experience so far with no-strings has been good, but we'd appreciate
> advice on how to best use Empire DB persistence patterns.
> 
> The webapp has five model objects, persisted to h2 for development /
> Oracle in production. Maven, Spring for DI only, liquibase for DB migration,
> TestNG/Surefire. We created a PersistenceManager class just like the Spring
> example, and injected it with WikiMgtDB (extends DBDatabase), a
> DataSource, and the Empire DB Driver. The PM class grew large with
> get/search/updates for the business objects, so we created DAO classes for
> each model object and injected each with WikiMgtD via Spring.
> 
> The PersistenceManager is injected into the Apache Click action classes for
> the webapp and can retrieve/store objects, but is not much more than a
> proxy that gives each DAO classes a Connection (see example).
> 
> PersistenceManagerImpl {
> ....
>   public SpaceSummary getSpaceSummary(String serverName, String
> spaceKey) {
>         Connection conn = getConnection();
>         spaceSummaryDAO.setConnection(conn);
>         SpaceSummary ss =
> spaceSummaryDAO.getSpaceSummary(serverName, spaceKey);
>         releaseConnection(conn);
>         return ss;
>     }
> 
> This pattern seems wrong, and test cases cannot be written against the DAO
> objects directly because they don't have a Connection.
> (A related puzzle is connection and transaction management which has been
> problematic with @Transactional annotations across updates involving more
> than one DAO. )
> 
> I've looked over most all of the sample code, found a lot of good ideas, but I
> need advice on EmpireDB patterns with more than one DAO, patterns for
> retrieving nested objects, proper connection management, and also how to
> best handle "paged" retrieval of 90,000 records.
> 
> Thanks in advance for any/all comments/feedback...and I'm happy to provide
> more details and contribute lessons back into more example code. (ex, a
> sample Apache Click + Empire DB)
> 
> Thanks!
> Tim
> 
> 

Reply via email to