• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

SessionHolder cannot be cast to EntityManagerHolder problem  RSS feed

 
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone!

I'm fighting with ClassCastException problem caused by Spring and Hibernate. I'd love you get some hints from you. Ive already tried to search this problem, but have not got any tip that works for me.

Cheers!



Category class:



CategoryDAO



web.xml



dispatcher-servlet.xml:



applicationContext.xml



Libs:

 
Jacek Rajczak
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like image link to libraries doesn't work so I will post it as link to imgur.


Libraries in Intellij
 
Ranch Hand
Posts: 630
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have set up your session factory in your context.xml

why dont you pass that into your repository and then create your hibernate  sessions  that way.


Then in your repository
[code]
public class FundRepositoryImpl extends MappEntitiesAbstract implements FundRepository {

private SessionFactory sessionFactory;

private static final Logger logger = LoggerFactory.getLogger(FundRepositoryImpl.class);

public void setSessionFactory(SessionFactory sessionFactory) {
       this.sessionFactory = sessionFactory;
   }
   
@Override
public List<FundPOJO> findFunds(List<Long> fundIds) {
Session session = this.sessionFactory.getCurrentSession();
Cache cache = sessionFactory.getCache();
Transaction tx = session.beginTransaction();
Query res = session.createQuery("FROM Fund f WHERE f.fundId IN :fundIds").setParameterList("fundIds", fundIds);
List <Fund>fundsList = res.setCacheable(true).list();
List<FundPOJO> funds = mapFunds(fundsList);
tx.commit();
return funds;
}
[code]
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!