Spring Webflow: 2.3.1
Spring Data: 1.0.2
JSF: 2.1.9
Primefaces: 3.3.1
I'm trying to combine Spring Data JPA Repositories with JSF DataModel, in this case, Primefaces with LazyDataModel. This happens in a WebApp integrating Spring with JSF, using Spring Webflow.
The problem is when i use a JpaRepository inside LazyDataModel that lives in ViewScope of Spring Webflow:
Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.(SerializedFlowExecutionSnapshot.java:75)"
Without the JpaRepository inside LazyDataModel, i cannot get the correct page and use the Pagination model of spring data. I already found someone with the same problem, but unfortunately no one answered:
Thanks for you help in advance
Best regards
JSimas
Already found a solution for this problem!
Whenever you need to add a reference to a Spring Data JPA Repository in an object that will live in your spring webflow context, just to declare the JPA repository as transient! Then you need to add the following annotations in the object that contain the transient reference:
So, if you're extending a DataModel JSF base class, and you want to add some JPA repository, here is an example:
@Configurable
public class XptoLazyDataModel extends LazyDataModel<Xpto> {
@Autowired
private transient JpaRepository<Xpto> repository;
(...)
}
And there you go. Hope that this can help someone.
Best regards