Answered Questions

  • What is database persistence?How well it is implemented in Hibernate

    Star Read Best Answer

    Editorial / Best Answer

    mani.sivapuram  

    • Member Since May-2010 | Feb 14th, 2011


    There are mainly three states in hibernate
    a) Transient state
    b) Persistant state
    c) Detatched state

    Take the employee object place the data in that object like usename, password, empid. Now the state of the object is transient state, when we write the statement given below

    session.save(employeeObject);

    Now the state of the object is persistent since the employee object is kept in session object then when we write the statement given below

    transaction.commit();

    When we apply the above statement then the employee object is going to linked with database and the data is stored in related table of that database. Since the emp object in persistent state only the data is stored in database other wise the data is not stored in database.

    After the commit operation it becomes into detached state. If anybody wants to store the emp object into database then in detached state it is not possible.