[EJB 3.0] - deleting entities from a Collection
by aberezin
Sorry if this is a bit of a repost. I am trying to figure out the best way to remove enties from a OneToMany collection (either uni or bidirectional).
I have an entity Foo, that contains a OneToMany Set:
Set getBars()
If I add new Bar objects to the set and call em.merge(myFoo), it properly persists the new Bar objects. However, simply removing Bar objects from the set and calling em.merge(myFoo) does not remove the underlying Bar objects from the db. It seems I have to explicitly call em.remove(myBar1), ...
Is this how thinks are suppose to work? I could see in a ManyToMany that you could not delete the underlying row simply because it is no longer in the Set. However, in a OneToMany, it would seem that the any Bar objects no longer in the set should be deleted.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970179#3970179
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970179
19 years, 7 months
[JBoss Seam] - How to configure jbpm to use an extended persistence context
by hazlorealidad
I am trying to print out the processes defined in the JbpmContext
and their nodes.
I get the message
failed to lazily initialize a collection of role: org.jbpm.graph.def.ProcessDefinition.nodes, no session or session was closed
The bean
public class ProcessManagerBean
{
@Logger
private Log logger;
@In(create=true)
JbpmContext jbpmContext;
@DataModel
private List processList;
@DataModelSelection
@Out(required=false)
private ProcessDefinition process;
@PersistenceContext(type=EXTENDED)
private EntityManager em;
//not used yet
@Out(required=false)
private List nodeList;
@Factory("processList")
public void findMessages()
{
GraphSession graph = jbpmContext.getGraphSession();
processList=graph.findLatestProcessDefinitions();
}
....
A fragment from the page is
<h:dataTable id="someTable" var="proc" value="#{processList}" rendered="#{!empty processList}">
<h:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:commandLink value="#{proc.name}" action="#{processManager.select}"/>
</h:column>
</h:dataTable>
<h3><h:outputText value="#{process.name}"/></h3>
<h3><h:outputText value="#{process.nodes}"/></h3>
The exception is caused by adding the last line
My guess is that the jbpm session is not using an extended persistence context
If thats the case how do I get it to use one.
If not what is the problem.
Thanks
Andy Bailey
www.hazlorealidad.com
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970178#3970178
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970178
19 years, 7 months