hi Upayavira
hibernate seem to be a good choice but is supported in production level
from cocoon?
are some examples in cocoon distribution?
i suppose that your example has to do with flow ? (right? )
---stavros
On Tue, 18 May 2004, Upayavira wrote:
> Derek Hohls wrote:
>
> >I am looking to try and build-up my learning on forms and flow (and
> >templating!) by applying this to a simple interactive database app.
> >
> >In the past, I used XSP and ESQL, along with a primitive "meta forms"
> >XML file to generate a generic form *and* populate it with data,
> >followed
> >by styling with XSLT. Database add/update/delete were then handled by
> >
> >database actions in the sitemap (along with the corresponding table
> >definition files). This approach may seem crude and simple but it
> >worked
> >and bugs (if any) were usually in a single XSP file and easy to track
> >down.
> >
> >I am now wondering what combination of "new" options to adopt in order
> >to replicate this approach in the simplest possible manner - I know
> >there has been lots of discussion on persistence frameworks; DTO's,
> >DAO's and business objects - but all this seems very much like over-
> >kill just to tackle a few tables with a few users (in other words, a
> >normal in-house, customised database app). I have seen flow samples
> >with binding to beans and XML files, but nothing in terms of building
> >up
> >forms dynamically and then hooking then to a normal relational database
> >
> >to read/write data.
> >
> >
> I know that people keep harking back to O/R mapping. I've just done my
> first bit of hibernate, which I've always been mildly scared of ("isn't
> it overkill???"). I couldn't believe it was that easy. You create an
> object, and then persist it. Easy:
>
> Here's the code to create a new User object:
> net.sf.hibernate.Session session = sessionFactory.openSession();
> Transaction transaction = session.beginTransaction();
> User user = new User();
> user.setEmail("[EMAIL PROTECTED]");
> user.setName("Upayavira");
> session.save(user);
> transaction.commit();
>
> That is it. And then that user object and persist it. You can make an
> object like that, and bind it to a form. The object is yours, it is of
> your design.
>
> Or to check whether a user exists or not with a simple query from a
> login form:
>
> try {
> transaction = session.beginTransaction();
> Query query = session.createQuery("from
> com.yoursite.formModels.User as user where user.email= :email and
> user.password=:password");
> query.setString("email",
> aForm.getChild("email").getValue().toString());
> query.setString("password",
> aForm.getChild("password").getValue().toString());
> result= (query.list().size()!=0);
> transaction.commit();
> } catch (Exception e){
> transaction.rollback();
> throw e;
> } finally {
> session.close();
> }
> return result;
>
> That's how easy it is in Hibernate. Don't know about OJB. I've got a
> feeling I'll be using O/R mapping for all sites I work on now that have
> a relational DB involved, it seems that easy.
>
> Hope I'm not banging a tired drum!
>
> Regards, Upayavira
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]