[JBoss Seam] - Howto handle LazyInitializationException
by thierry.rietsch
Hello
I have a problem with lazy loading and need a workaround.
I have an Entity called SoftwareInventoryObject which contains a Collection of SoftwareInventoryObjectParts.
| class SoftwareInventoryObject {
| // other fields
| List<SoftwareInventoryObjectPart> parts;
|
| // Getter & Setter
| }
|
Additionally I have a EJB3 Bean SoftwareObjectSearch which searchs in the database for the above mentioned SoftwareInventoryObjects.
| class SoftwareObjectSearch {
| // other code
|
| @DataModel
| List<SoftwareObjectPart> inventoryObjects;
|
| // other code
| }
|
To view the result I have a facelet which contains a <h:dataTable>. Now I would like to display each of the SoftwareObjectParts too therefor I have a nested <h:dataTable> in the facelet.
| <h:dataTable value="#{inventoryObjects}" var="sio" rendered="#{inventoryObjects != null}">
| <h:column>
| <h:dataTable value="#{sio.parts}" var="siop">
| <h:column><f:facet name="header">Name</f:facet> #{sio.name}</h:column>
| <h:column><f:facet name="header">Type</f:facet> #{sio.type}</h:column>
| <h:column><f:facet name="header">Barcode</f:facet> #{sio.barcode}</h:column>
| <h:column><f:facet name="header">Manufacture</f:facet> #{sio.manufacture}</h:column>
| <h:column><f:facet name="header">Distributor</f:facet> #{siop.distributor}</h:column>
| <h:column><f:facet name="header">Order Number</f:facet> #{siop.orderNumber}</h:column>
| <h:column><f:facet name="header">Price</f:facet> #{siop.price}</h:column>
| <h:column><f:facet name="header">Version</f:facet> #{siop.version}</h:column>
| <h:column><f:facet name="header">Action</f:facet> link</h:column>
| </h:dataTable>
| </h:column>
| </h:dataTable>
|
Now when I run a facelet I get a Lazy Initalization Exception for the siop, the SoftwareInventoryObjectPart. This makes sense to me, because I access a collection which is not eager loaded, after the initial Hibernate session was closed. My question is now, how can I avoid such an exception? What is a nice workaround.
If you need any further code please let me know. Thanks for all the answers in advance.
Thierry
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048194#4048194
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048194
18 years, 11 months
[JBoss Seam] - Radiobutton and AJAX
by miloslav.vlach
Hi all,
I have problem with this scenario:
I would like to have an form with some input text fields. On the form will be an group of radiobuttons which control the form. When I clicked on the first radiobutton, some imput texts disappears and some appears. I can do that with ajax4jsf - no problem. But problem is when some field are required. When the field is required the ajax request is called but response is not applied.
I am trying to call immediate="true" but it doesn't work, singleRequest="true" ......
Can somebody help me ?
Thanks Mila
| <s:decorate template="/editspan.xhtml">
| <ui:define name="label">Typ:</ui:define>
| <h:selectOneRadio value="#{communicationAddAction.type}">
| <f:selectItem itemValue="1" itemLabel="phone" />
| <f:selectItem itemValue="2" itemLabel="email" />
| <f:selectItem itemValue="3" itemLabel="person" />
| <a:support action="#{communicationAddAction.changeType}" event="onchange" reRender="method" singleRequest="true" ajaxRendered="true"/>
| </h:selectOneRadio>
| </s:decorate>
|
| ....
|
| <a:outputPanel id="method">
|
| <s:fragment rendered="#{communicationAddAction.showEmailContact}">
| <s:decorate template="/editspan.xhtml">
| <ui:define name="label">E-mail:</ui:define>
| <h:inputText value="#{communication.personEmail}" required="true"></h:inputText>
| </s:decorate>
| </s:fragment>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048183#4048183
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048183
18 years, 11 months