[jboss-user] [JBoss Seam] - fetchtype.LAZY results in JSF validation error
roeber
do-not-reply at jboss.com
Sat Nov 4 15:11:51 EST 2006
I found out that setting fetchtype.LAZY on a manyToOne association results in a JSF validation error for an selectOneMenu component.
| @ManyToOne(fetch=FetchType.LAZY)
| public OrgUnit getOrgUnit() {
| return orgUnit;
| }
|
| <t:selectOneMenu id="orgunit" required="true" value="#{activity.orgUnit}" converter="orgunitconverter">
| <f:selectItems value="#{selectitemservice.orgUnitChoices}"/>
| </t:selectOneMenu>
|
| public Object getAsObject(FacesContext context, UIComponent comp,
| String value) throws ConverterException {
|
| if (!StringUtils.isNumeric(value))
| return null ;
|
| Long id = Long.valueOf(value);
| Object object = em.find(OrgUnit.class, id);
|
| return object ;
| }
|
| public String getAsString(FacesContext context, UIComponent component,
| Object object) throws ConverterException {
|
| if (object == null) {
| return null;
| }
| if (object instanceof OrgUnit) {
| OrgUnit orgUnit = (OrgUnit)object ;
| String returnString = orgUnit.getId().toString();
| return returnString;
| }
| return null ;
| }
|
The converter for OrgUnit seems to work: All units are displayed in the drop-down box and the current unit is also selected correctly in the box.
But submitting a page with this component shows a validation error saying: "orgunit": Value is not a valid option.
There are many things which could go wrong on my side but just removing the 'fetch=fetchtype.LAZY' (and therefore implicitly changing fetchtype to EAGER) results in a perfect working dialog. I suspect the use of a proxy for lazy fetching in Hibernate causing this, but debugging and tracing the converter and equals methods doesn't help me.
Any ideas would be appreciated.
--
Axel
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983241#3983241
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983241
More information about the jboss-user
mailing list