/*--------------------------------------------------------------------------- * running inserting pgm with hibernate 1.2.5 * * *----------------------------------------------------------------------------*/ public class HibernateTest { public static void main(String[] args) { HibernateTest hibernateTest = new HibernateTest(); } public HibernateTest() { Session session; try { //store data ----------------------------------------------------------------- Datastore ds = Hibernate.createDatastore(); ds.storeClass(User1.class); // Then build a session to the database SessionFactory sf = ds.buildSessionFactory(); // or supply a Properties arg session = sf.openSession(); // Create new User and store them the database User1 newUser1 = new User1(); newUser1.setID("dr"); newUser1.setUserName("pia2 raschpichler"); // And the Hibernate call which stores it session.save(newUser1); // close our session and release resources session.flush(); session.close(); } catch (MappingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }-- OtherDenisRaschpichler - 06 Dec 2004
Topic TestExampleWithHibernate12 . { Edit | Attach | Ref-By | Printable | Diffs | r1.2 | > | r1.1 | More } |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors.
|
This website has been archived and is no longer maintained.