Win a copy of Java XML & JSON this week in the XML and Related Technologies forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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]
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!