20031109: Updated for Cocoon CVS 2.1.3 (8 nov 2003) and for Hibernate 2.1b6
20031113: Updated the attachment. Removed the classes already supplied by Woody.
WEB-INF/lib
. Copy only the jars that are not yet present. And don't forget the Hibernate jar itself (it is not in the Hibernate lib directory)WEB-INF
of the zip file (see attachment) into your Cocoon WEB-INF
._cocoon.xconf
into your real cocoon.xconf
(this adds the Avalon component that creates the Hibernate session)hibernate.properties
in WEB-INF/classes
. Insert your login credentials for your databasemysql.sql
script. (Hibernate has support for many different databases. Change the SQL dialect in hibernate.properties
and edit this script if don't use mysql but something else.Hibernate initialize called
. If you don't see this line, one of the points above went wrong.http://...../woody/
This is how it works:
PersistenceFactory
and its implementation HibernateFactory
). This component creates the Hibernate session.binding_example.js
is changed a little. The function form2bean
tries to load the Form2Bean
object from disk with a hard-coded email address as the key. If it fails, it creates a new instance and saves it to disk.WEB-INF\classes\org\apache\cocoon\woody\samples\Form2Bean.hbm.xml
. This configuration file tells Hibernate how to do the real work: hide all details about the one-to-many relation (contacts that are added to the bean) for the developer. When you play with the example and look into the database, you can see that contacts are added with an unique key that is generated by Hibernate (the id field; don't edit it, as the Woody intructions tell you) and a foreign key (the email address). In a real-world application, you almost always will need the lazy
and inverse
attributes. But in this case, I wanted to stay as close as possible to the original classes of the Woody sample.
Hugo Burm
Attachment: Hibernate_Woody_Flow.zip