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.

Results 1 to 3 of 3

Thread: Method getCurrentSession() is Undefined for SessionFactory

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Location
    Bangalore
    Posts
    20
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Method getCurrentSession() is Undefined for SessionFactory

    What does it mean by "Method getCurrentSession() is Undefined for SessionFactory" it is showing in my program. Please tell me ..


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Method getCurrentSession() is Undefined for SessionFactory

    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?

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Location
    Bangalore
    Posts
    20
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Method getCurrentSession() is Undefined for SessionFactory

    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]

Similar Threads

  1. method undefined error
    By Herah in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 29th, 2011, 08:38 PM
  2. Replies: 3
    Last Post: October 28th, 2011, 04:42 PM
  3. constructor X is undefined
    By ober0330 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: August 24th, 2011, 01:51 PM
  4. Undefined Array Problem
    By oakheart in forum Other Programming Languages
    Replies: 2
    Last Post: April 18th, 2011, 09:19 AM
  5. he operator / is undefined for the argument type(s) String, int
    By mtbr00x in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: September 8th, 2009, 08:34 PM