JSF-Hibernate, how to insert a NULL value in h:selectOne list
843842Jan 5 2006 — edited Feb 7 2006Hi all!
I have a problem with SelectItems... precisely, I use them to manage a many-to-one relation in the database. I use Hibernate for persistence, but it does not influence the problem. This could be a critical situation using EJB too.
Imagine two entities: Person and Group. The many-to-one relation I have is "a person is in group" or "a group contains many persons".
So, I create a JSP to manage person informations and there I put a selectOneMenu in order to choose the group in which the person is. But in my case a person could be out of a group, and database allow that a person has the group field NULL, but I do not know how manage this situation with SelectOneMenu.
I suppose:
- to insert a null valule in the SelectItems list: but a JasperException occurs. I think that probably JSF does not allow null values;
- so, to insert a not-null value in the list, I confuse the Hibernate collection that represents the relation; Hibernate throws an exception;
- a stupid solution is to insert a real value, but null of sense in the database... that is bad solution for the database meaning.
So, if someone has a better solution than mine, thanx for your help!
cloud