Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1.3
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Session s = SessionFactoryHibernate.getCurrentSession();
Transaction tx = s.beginTransaction();
Flight fli = new Flight ();
fli.setFlightName("boy747");
s.save(fli);
System.out.println("new id="+fli.getFlightId());
tx.rollback();
//If I use "load" first , and then clear, and then "load" or "createQuery", I cannot find the boy747 object. But If I use "createQuery" first , and then clear, and then "load","createQuery" , I still can find the object unless I start a whole new session factory!
//Flight ff = (Flight)s.load(Flight.class, fli.getFlightId() );
Flight ff =(Flight) s.createQuery("from Flight f where f.flightId=:id").setParameter("id", fli.getFlightId()).uniqueResult();
//assertNull(ff);
System.out.println(ff.getFlightId());
s.clear();
Flight fff = (Flight)s.load(Flight.class, fli.getFlightId() );
System.out.println(fff.getFlightId());
Full stack trace of any exception that occurs:
Name and version of the database you are using:mssql 2000 and mysql latest version
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: