Sam Gendler wrote:
...
The nice thing is that if
examples use a fairly generic DAO abstraction, it should be possible
to provide nice examples that aren't dependant upon any particular
suite of technologies. Just describe the DAO interface and then use
those them to access standard POJOs. Obviously, most folks will
probably be doing a Hibernate/Spring thing, so addressing best
practices for combin ing those technologies with Wicket is enormously
valuable, but it should be secondary to providing generic best
practices for dealing with DAO access, detachability, etc.
...
1. hibernate/spring integration (separate from wicket)
2. hibernate/spring/wicket best practices
Sam -- all of what you propose sounds excellent.
[The tradional example has been the pet shop, but nowadays, I think a
blogging system is a nice worked example for a web framework.]
I haven't had a chance to look at Igor, et al's new Spring integration,
but here are a few bits of advice from my experiments with
Wicket/Spring/Hibernate:
- If you're using Spring to manage your DAOs, you don't need to look at
wicket-contrib-hibernate.
- Spring and Hiberate already integrate together really easily. Take a
look at org.springframework.orm.hibernate3.LocalSessionFactoryBean. They
should have plenty of examples, but if you need a more complete
spring.xml, let me know and I'll send you one.
- To map Hibernate sessions to requests, Spring AOP's
OpenSessionInViewInterceptor makes everything automatic. Here's what I
use:
<!-- The openSessionInViewInterceptor is for Wicket requests; the
HibernateInterceptor
is for business objects -->
<bean name="openSessionInViewInterceptor"
class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory"><ref
bean="sessionFactory"/></property>
<property
name="flushModeName"><value>FLUSH_AUTO</value></property>
</bean>
- For an example of Transaction Templates, take a look at
http://blog.exis.com/colin/archives/2004/07/31/concise-transaction-definitions-spring-11/
- If you can get to the DAOs from your pages or models and your Sessions
are managed correctly, using them with Wicket is very easy.
- I'm not yet sure what the best practice for detatching is. If you have
relatively small objects and plety of RAM, you could use hibernate's
lock() function to attach to the current Hibernate session. Most likely,
though, having your models keep the id of the object and loading them from the
DAO maks the most sense.
Good luck,
Dan
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user