我有一个" Profissional"与" City"具有@ManyToOne单向关系的实体。然后,当执行如下的查询...
@ManyToOne(targetEntity=Cidade.class)
@JoinColumn(name="IDE_CIDADE_DOMICILIO_FISCAL",nullable=true)
public Cidade getCidadeDomicilioFiscal() {
return cidadeDomicilioFiscal;
}
return query.scroll();
...出现这个hibernate异常。我也试过在Profissional方面包含cascade = CascadeType.ALL,没有效果。还有@Cascade对Hibernate的注释,如下所示:
@Cascade(CascadeType.SAVED_UPDATE)
没有任何影响!
11:03:05,427 INFO [STDOUT] Hibernate:
select
nomeacao0_.IDE_COMPETENCIA_JUDICIAL as col_0_0_,
cidade2_.DES_CIDADE as col_1_0_,
unidade1_.DES_UNIDADE as col_2_0_,
categoriap5_.NOME_CATEGORIA as col_3_0_,
solicitaco3_.NUM_SOLICITACAO as col_4_0_,
processoju9_.NUM_PROCESSO as col_5_0_,
processoju9_.NOME_ASSISTIDO as col_6_0_,
profissao8_.NOME_PROFISSAO as col_7_0_,
especialid7_.NOME_ESPECIALIDADE as col_8_0_,
solicitaco3_.DATA_PRESTACAO_SERVICO as col_9_0_,
profission6_.NOME_RAZAO_SOCIAL_PROFISSIONAL as col_10_0_,
profission6_.NUM_CPF_CNPJ as col_11_0_,
solicitaco3_.VAL_BRUTO as col_12_0_,
nomeacao0_.QTD_ASSISTIDOS as col_13_0_,
cidade10_.DES_CIDADE as col_14_0_
from
O_AJ.NOMEACAO nomeacao0_
inner join
O_AJ.UNIDADE unidade1_
on nomeacao0_.IDE_UNIDADE=unidade1_.IDE_UNIDADE
inner join
O_AJ.CIDADE cidade2_
on unidade1_.COD_CIDADE=cidade2_.COD_CIDADE
inner join
O_AJ.SOLICITACAO_PAGAMENTO solicitaco3_
on nomeacao0_.IDE_NOMEACAO=solicitaco3_.IDE_NOMEACAO
inner join
O_AJ.UNIDADE unidade4_
on solicitaco3_.IDE_UNIDADE=unidade4_.IDE_UNIDADE
inner join
O_AJ.CATEGORIA_PROFISSAO categoriap5_
on nomeacao0_.IDE_CATEGORIA_PROFISSAO=categoriap5_.IDE_CATEGORIA_PROFISSAO
inner join
O_AJ.PROFISSIONAL profission6_
on nomeacao0_.IDE_PROFISSIONAL=profission6_.IDE_PROFISSIONAL
inner join
O_AJ.CIDADE cidade10_ <<===== HERE IS MY JOIN
on profission6_.IDE_CIDADE_DOMICILIO_FISCAL=cidade10_.COD_CIDADE
left outer join
O_AJ.ESPECIALIDADE especialid7_
on nomeacao0_.IDE_ESPECIALIDADE=especialid7_.IDE_ESPECIALIDADE
left outer join
O_AJ.PROFISSAO profissao8_
on nomeacao0_.IDE_PROFISSAO=profissao8_.IDE_PROFISSAO
left outer join
O_AJ.PROCESSO_JUDICIAL processoju9_
on nomeacao0_.IDE_PROCESSO_JUDICIAL=processoju9_.IDE_PROCESSO_JUDICIAL
where
unidade1_.IDE_UNIDADE=unidade4_.IDE_UNIDADE
and (
categoriap5_.IDE_CATEGORIA_PROFISSAO in (
'3'
)
)
and (
nomeacao0_.IDE_COMPETENCIA_JUDICIAL in (
'2'
)
)
and (
solicitaco3_.DATA_SOLICITACAO_PAGAMENTO between ? and ?
)
and unidade1_.IND_ATIVO=1
and unidade1_.IDE_REGIAO=?
and (
profission6_.IDE_CIDADE_DOMICILIO_FISCAL is not null
)
and cidade10_.COD_CIDADE=?
and length(profission6_.NUM_CPF_CNPJ)<=11
and (
solicitaco3_.COD_SITUACAO_SOLICITACAO in (
4
)
)
order by
nomeacao0_.IDE_COMPETENCIA_JUDICIAL,
unidade1_.COD_CIDADE,
nomeacao0_.IDE_CATEGORIA_PROFISSAO,
unidade1_.DES_UNIDADE
11:03:05,432 ERROR [STDERR] javax.faces.el.EvaluationException: /pagamento/consultarsolicitacoes/consultarsolicitacoes_principal.xhtml @338,25 actionListener="#{visao.verificaConteudoRelatorio}": org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: cjf.aj.comum.negocio.Cidade
11:03:05,433 ERROR [STDERR] at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
11:03:05,433 ERROR [STDERR] at javax.faces.component.UICommand.broadcast(UICommand.java:89)
11:03:05,433 ERROR [STDERR] at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
11:03:05,433 ERROR [STDERR] at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
11:03:05,433 ERROR [STDERR] at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
11:03:05,433 ERROR [STDERR] at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
11:03:05,433 ERROR [STDERR] at org.apache.myfaces.lifecycle.JFSCLifecycle.executePhase(JFSCLifecycle.java:74)
11:03:05,433 ERROR [STDERR] at org.apache.myfaces.lifecycle.JFSCLifecycle.execute(JFSCLifecycle.java:49)
11:03:05,433 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,433 ERROR [STDERR] at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,433 ERROR [STDERR] at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
11:03:05,433 ERROR [STDERR] at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,433 ERROR [STDERR] at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,433 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,434 ERROR [STDERR] at cjf.aj.comum.apresentacao.AJMultiPartFilter.doFilter(AJMultiPartFilter.java:77)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,434 ERROR [STDERR] at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:43)
11:03:05,434 ERROR [STDERR] at cjf.aj.comum.apresentacao.AJCharacterEncoding.doFilter(AJCharacterEncoding.java:42)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,434 ERROR [STDERR] at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,434 ERROR [STDERR] at cjf.aj.comum.log.AJGExceptionFilter.doFilter(AJGExceptionFilter.java:25)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,434 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,434 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
11:03:05,435 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
11:03:05,435 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
11:03:05,435 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
11:03:05,435 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
11:03:05,435 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
11:03:05,435 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
11:03:05,435 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
11:03:05,435 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
11:03:05,435 ERROR [STDERR] at java.lang.Thread.run(Thread.java:745)
11:03:05,436 ERROR [STDERR] Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: cjf.aj.comum.negocio.Cidade
有人可以帮忙吗?
答案 0 :(得分:1)
没关系,
这个版本的hibernate不接受可序列化对象作为参数。
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.0.SP1</version>