| Joined: Thu Sep 02, 2004 8:33 am
 Posts: 6
 | 
				
					| Hello,
 I am new to hibernate so maybe it is a stupid question.
 I have made a simple application:
 public static void main ( String[] args )throws HibernateException
 {
 Configuration cfg = new Configuration();
 cfg.addClass(ch2.Message.class);
 
 SessionFactory sf = cfg.buildSessionFactory();
 Session session = sf.openSession();
 Transaction tx = null;
 
 try{
 tx = session.beginTransaction();
 Message message = new Message("Hello World");
 Message nMes = new Message("hibernate");
 
 session.save(message);
 session.save(nMes);
 tx.commit();
 } catch (HibernateException e) {
 if (tx!=null)
 tx.rollback();
 throw e;
 }
 finally {
 
 session.close();
 }
 }
 
 Everything is working fine he's writing the messages to the database.
 Only i have a problem when i'm running the application again i want to right the same values again to the database. So i have 4 messages in the database:
 
 1 -- Hello World
 2 -- hibernate
 3 -- Hello World
 4 -- hibernate
 
 but it looks like he overwrite the values in the database so the result is everytime:
 
 1 -- Hello World
 2 -- hibernate
 
 anybody a suggestion?
 
 Bart
 
 
 |  |