hibernate-4-spring-3.1-samples icon indicating copy to clipboard operation
hibernate-4-spring-3.1-samples copied to clipboard

sessionFactory.getCurrentSession();

Open ghost opened this issue 13 years ago • 3 comments

i have open session in oracle and session limit problem when i use getSession.openSession();//session limit in oracle and sessionFactory.getCurrentSession();//have problem in that session not exist in thread i config @transcation by i get not open session in lazy loading (session close)

i dont know how do it plz help meeee plzzzzz

@Autowired private SessionFactory sessionFactory;

@Override
public List<T> getAll() {
    Criteria criteria = getSession().createCriteria(domainClass.getName());
    return criteria.list();
}

public Session getSession() {
        return sessionFactory.getCurrentSession();
}

ghost avatar Jul 09 '12 18:07 ghost

Hi Ali, your code sample looks good to me (assuming that you did inject the sessionFactory properly as in my sample application). So it might be that you're having issues in your Oracle datasource configuration. Sorry I can't help you on that specific point but I'm sure you'll find plenty of examples on Internet. You can also ask on the Spring forums here: http://forum.springsource.org/forumdisplay.php?27-Data

Cheers, Michael.

michaelisvy avatar Jul 10 '12 03:07 michaelisvy

So how does one make this example work when it is not being run as a JUnit test? I can't get the transactional part to work outside of JUnit and always get a org.hibernate.HibernateException: No Session found for current thread.

faroe228 avatar Jan 20 '13 01:01 faroe228

so same

pandahk avatar Feb 04 '16 02:02 pandahk