Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selectManyCheckbox LazyInitializationException on process validation

Tags:

jsf

mojarra

It appears that if you use a selectManyCheckbox backed by a set that is proxied by hibernate you will run into problems with the dreaded LazyInitializationException. This has nothing to do with the state of the backing bean!

After debugging Mojarra 2.1 I discovered that if you do not included the attribute collectionType it will attempt to clone the backing value class in the process validations phase, which in my case is PersistentSet. Of course adding any value to this will cause a LazyInitializationException.

My question is whether you think this is reasonable behaviour at the process validations phase?

A better algorithm to clone the collection class would be to look at the interface and instantiate a known class from java.util.

like image 524
Andrew Wheeler Avatar asked Apr 10 '11 09:04

Andrew Wheeler


1 Answers

Thats exactly the point! It has nothing todo with the session state... I've ran into this problem and I was able to solve it by adding the following within my component (in my case a selectManyMenu):

<f:attribute name="collectionType" value="java.util.ArrayList" />;
like image 163
JoaoPauloPaschoal Avatar answered Nov 07 '22 20:11

JoaoPauloPaschoal