facebook

[Closed] Refreshing a hibernate session

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #265755 Reply

    houcine
    Member

    help pleas
    i m working with myeclipse
    i wold like to know how i can refresh my hibernate session

    #265780 Reply

    Haris Peco
    Member

    houcine,

    Where you want refresh session : in MyEclipse HQL (Criteria) editor, in your application ?
    Why you need refresh ?

    Regards,

    #265798 Reply

    houcine
    Member

    Hi , Thanks .

    My problem the delete works in the database but the object still exists in hibernate. Here is the code:

    String req=”delete from TempFacture where userId=:userId”;
    Session session = HibernateSessionFactory.currentSession();
    Transaction tx = session.beginTransaction();
    int deletedEntities =session.createQuery( req ).setInteger(“userId”, id.intValue() ).executeUpdate();
    tx.commit();
    session.close();

    tanks again

    #265822 Reply

    Haris Peco
    Member

    Houcine,

    There isn’t command ‘remove from …’ in Hibernate.You have to got error in log or console
    Try the following query :

    String req=”delete TempFacture where userId=:userId”;

    Regards,

    #265827 Reply

    houcine
    Member

    hi
    it is a writing mistake i want write delete ,
    so my problem is delete works in the database but the object still exists in hibernate

    #265831 Reply

    Haris Peco
    Member

    Try call session.refresh().
    It is better that you use session.delete(Object obj) for deleting object in hibernate.
    executueUpdates is used for only long operation (big updates) and it is execute direct to database.

    Regards,

    #265874 Reply

    houcine
    Member

    thinks for your help

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: [Closed] Refreshing a hibernate session

You must be logged in to post in the forum log in