Vaadin 7 + Spring 3 + Hibernate 4 (with spring-vaadin addon)

Hi all,

I’m currently doing a new project, and i wanna use Vaadin 7 + Spring 3.2.3 + Hibernate 4.2.1.

But, i’ve got some problems.

I’ve found an addon “spring-vaadin” to do the link between Spring and Vaadin.

All seems to be good, except the @Autowired management.

It’s a regular problem with Spring and Hibernate, but no way to find a solution to do with Vaadin structure.

I have this pattern : User (Bean) → UserDao → UserService
In my first page, i want to do userService.findAll();

But i got an exception
“org.hibernate.HibernateException: No Session found for current thread

In some forum, it’s preconized to split root context transaction manager (for entities/repositories/services) and application context transaction manager (for controlers).

User is defined as ENTITY
UserDao is defined as REPOSITORY and TRANSACTIONAL
UserService is defined as SERVICE and TRANSACTIONAL

i’m using @Autowired to inject dao into service and to inject service into UI

My configuration files :

I can post my projet without problems.

How can i solve that please ?

Thanks by advance.

Hi Romuald,

I think you are mixing the thing up. One thing is the dependency injection and that is what you can have from Spring DI (or any other DI framework). Another thing is the hibernate session management and the transaction management in general. These can be done by spring or any other mean as well but has nothing to do with DI.

You can take a look to OpenEntityManagerInViewFilter from Spring to cover these aspects.

By the way, these topics are not much Vaadin related. It is more a web application architecture aspect.