import java.util.*; import net.sf.hibernate.*; import com.minosis.hibernate.*; public class Test { public static void main(String[] args) throws HibernateException { Session session = HibernateUtil.currentSession(); // Lecture avec conditions /* List list = session.find("from TContact where nom like '%t'"); Iterator it = list.iterator(); while(it.hasNext()) { TContact contact = (TContact)it.next(); System.out.println(contact.getNom()); } */ Transaction tx= session.beginTransaction(); // update /*TContact contact = (TContact) session.load(TContact.class, new Integer(1)); contact.setNom("Jean"); session.save(contact);*/ // insertion /*TContact contact = new TContact(); contact.setNom("Dupont"); contact.setPrenom("Jean"); contact.setAge(new Integer(44)); session.save(contact); contact = new TContact(); contact.setNom("Lambert"); contact.setPrenom("Julie"); contact.setAge(new Integer(27)); session.save(contact); tx.commit(); HibernateUtil.closeSession();*/ // lecture List list = session.find("from TContact where nom like '%t'"); Iterator it = list.iterator(); while(it.hasNext()) { TContact contact = (TContact)it.next(); System.out.println(contact.getNom()); } HibernateUtil.closeSession(); } }