i use spring3 with hibernate3 and jsf2 with primefaces..
I have a problem when i try to load data from the db , i get null pointer Exception as the session factory is null !
I think the problem comes from :
when i made my managedBean in the viewscoped it gives me “Not serializable Exception” so i make all the class members implement serialaizable but it also gives me the not serializable Exception but for this class “org.springframework.orm.hibernate3.LocalSessionFactoryBean” , so i made the session factory transient .
after i made the session factory transient the application works fine but if i made ajax request the session factory is null so i have null pointer exception !!!
any help will be appreciated..
thanks inadvance
Not really create a new session factory
You are using spring so reference tree must be something
ManagedBean -> Spring Service -> Spring Repository
Your managed beans should have reference to a service layer(Singleton). This reference you should mark as transient and fetch from application context in method hooks.
The service bean will always be available from context and you dont have to recreate any instance, its just you pick it back from context.
As for hibernate, it should be in Repository layer and since you have protected your service layer from serialization Repository will not be serialized and hence no issue as above.
Hope this helps !!!!!