What does it mean by "Method getCurrentSession() is Undefined for SessionFactory" it is showing in my program. Please tell me ..
Printable View
What does it mean by "Method getCurrentSession() is Undefined for SessionFactory" it is showing in my program. Please tell me ..
It means just that - the SessionFactory class you are referring to does not have that method. Given you have not mentioned which API you are using, and have not posted any code, we can only guess what package the SessionFactory class is a member of. Is this hibernate?
i am using spring hibernate api
[java]import java.util.List;
import net.form.Contact;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autow ired;
import org.springframework.stereotype.Repository;
@Repository
public class ContactDAOImpl implements ContactDAO {
@Autowired
private SessionFactory sessionFactory;
public void addContact(Contact contact) {
sessionFactory.getCurrentSession().save(contact);
}
public List<Contact> listContact() {
return sessionFactory.getCurrentSession().createQuery("fr om Contact")
.list();
}
public void removeContact(Integer id) {
Contact contact = (Contact) sessionFactory.getCurrentSession().load(
Contact.class, id);
if (null != contact) {
sessionFactory.getCurrentSession().delete(contact) ;
}
}
}[/java]