What does it mean by "Method getCurrentSession() is Undefined for SessionFactory" it is showing in my program. Please tell me ..
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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]