Pessoal quando executo getEntityManager().merge(bean); passando um bean do tipo PerfilBean ocorre a pilha abaixo (preciso que a collection relPerfilFuncionalidades também seja persistida)
O persist funciona perfeitamente, mas o merge(update) joga este stack…
Segue abaixo os mapeamentos que fiz:
[code]@Entity
@Table(name = “perfil”, catalog = “videodb”, schema = “”)
@NamedQueries({
@NamedQuery(name = “PerfilBean.listarTodos”, query = “SELECT p FROM PerfilBean p”),
@NamedQuery(name = “PerfilBean.listarPorDescricao”, query = “SELECT p FROM PerfilBean p WHERE UPPER(p.descricao) LIKE UPPER(’%’||:descricao||’%’)”)
})
public class PerfilBean extends BaseBean {
private static final long serialVersionUID = -4084222650476105363L;
public static final String LISTAR_TODOS = "PerfilBean.listarTodos";
public static final String LISTAR_POR_DESCRICAO = "PerfilBean.listarPorDescricao";
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Basic(optional = false)
@Column(name = "id_perfil")
private Integer idPerfil;
@Basic(optional = false)
@Column(name = "descricao")
private String descricao;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "chaveComposta.perfil", fetch = FetchType.LAZY)
private List<RelPerfilFuncionalidadeBean> relPerfilFuncionalidades;
//…RESTANTE DO CÓDIGO[/code]
[code]//…ANNOTAÇÕES SEMELHANTES AO DO BEAN PerfilBean
public class FuncionalidadeBean extends BaseBean {
private static final long serialVersionUID = -1434295796322037204L;
public static final String LISTAR_TODOS = "FuncionalidadeBean.listarTodos";
public static final String LISTAR_POR_DESCRICAO = "FuncionalidadeBean.listarPorDescricao";
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Basic(optional = false)
@Column(name = "id_funcionalidade")
private Integer idFuncionalidade;
@Basic(optional = false)
@Column(name = "descricao", nullable = false, length = 45)
private String descricao;
@Basic(optional = true)
@Column(name = "detalhe", nullable = false, length = 255)
private String detalhe;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "chaveComposta.funcionalidade", fetch = FetchType.LAZY)
private List<RelPerfilFuncionalidadeBean> relPerfilFuncionalidades;
//…RESTANTE DO CÓDIGO[/code]
[code]//…ANNOTAÇÕES SEMELHANTES AO DO BEAN PerfilBean
public class RelPerfilFuncionalidadeBean extends BaseBean {
private static final long serialVersionUID = 4883700235258089836L;
public static final String LISTAR_TODOS = "RelPerfilFuncionalidadeBean.listarTodos";
@EmbeddedId
private RelPerfilFuncionalidadePK chaveComposta;
@Basic(optional = true)
@Column(name = "pontos_minimos", length=6, nullable = true)
private Integer pontosMinimos;
//…RESTANTE DO CÓDIGO[/code]
[code]@Embeddable
public class RelPerfilFuncionalidadePK extends BaseChaveComposta {
private static final long serialVersionUID = -5358109374101523596L;
@JoinColumn(name = "id_perfil", referencedColumnName = "id_perfil")
@ManyToOne(optional = false, cascade = CascadeType.REFRESH)
private PerfilBean perfil;
@JoinColumn(name = "id_funcionalidade", referencedColumnName = "id_funcionalidade")
@ManyToOne(optional = false, cascade = CascadeType.REFRESH)
private FuncionalidadeBean funcionalidade;
//…RESTANTE DO CÓDIGO[/code]
SEVERE: java.lang.StackOverflowError
javax.faces.el.EvaluationException: java.lang.StackOverflowError
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
at javax.faces.component.UICommand.broadcast(UICommand.java:383)
at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.StackOverflowError
at java.io.BufferedWriter.write(BufferedWriter.java:202)
at java.io.Writer.write(Writer.java:140)
at java.io.PrintStream.write(PrintStream.java:475)
at java.io.PrintStream.print(PrintStream.java:619)
at java.io.PrintStream.println(PrintStream.java:756)
at org.apache.tomcat.util.log.SystemLogHandler.println(SystemLogHandler.java:238)
at org.hibernate.jdbc.util.SQLStatementLogger.logStatement(SQLStatementLogger.java:113)
at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:444)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:511)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1577)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1885)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3062)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:434)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:415)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:874)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:607)
at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:298)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1121)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:588)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1885)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3062)
Ficarei grato, por qualquer ajuda…
desde já obrigado pessoal!