Gosh, you can use Hibernate if you want, but I write plain DAO classes with JDBC & Wicket & they work just fine. No fuss, no muss. Just my take on it, though. I know there are some that like Hibernate. But try as I might, I've never been able to justify yet another third party library for my needs.
"There are three kinds of lies: lies, damn lies, and statistics." Benjamin Disraeli "Then there was the man who drowned crossing a stream with an average depth of six inches." W. I. E. Gates From: JASON HOLT <j_holt5...@msn.com> To: <users@wicket.apache.org> Date: 05/08/2012 03:37 PM Subject: Persistence. I'll repeat my plea for patience as I'm new to Java and Wicket, but have some minimal experience with ASP.net forms (not MVC). I've reached that point in the learning process where I want to interact with a database and I wish to use entities and Hibernate to make it easier. From what I've seen in various blogs and forums, some say you shouldn't use entities as models, yet others do it with LDMs. Since I'm taking baby steps, I want to start by using entities as models, unless someone convinces me I'm wasting my time. Following the basic Hibernate tutorials for persisting simple classes, I've managed to make the following work in Wicket. In the LDM load... @Override public Person load() { Session session = WicketApp.sessionFactory.openSession(); session.beginTransaction(); Person person = (Person) session.get(Person.class, 1L); session.getTransaction().commit(); session.close(); return person; } In the form I update the evil entity model with text boxes, using a CPM containing the LDM. In the submit button... public void onSubmit() { Session session = WicketApp.sessionFactory.openSession(); session.beginTransaction(); session.update(ldm.getObject()); session.getTransaction().commit(); session.close(); this.setResponsePage(EndPage.class); } The sessionFactory is a static member of the WicketApp application class, initialized in the init() method. This seems to work, but I suppose there are all kinds of faulty design patterns used here. My main concern is... how can I do this without opening a new Hibernate session in onSubmit()? During postback, I think I should be able to reuse the same session opened at ldm.load() in onSubmit() also, as it all occurs in the same request. Is this possible? Thanks for your assistance. Please feel free to point out every flaw. ** This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient. Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law. If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies. **