-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Caching Search?
PostPosted: Wed Sep 22, 2004 4:11 pm 
Beginner
Beginner

Joined: Tue Feb 10, 2004 8:22 am
Posts: 28
Hi!
I'm having problem with a search probably caused by cache.
I make the search and it works fine for the first time. Then I delete a register from the DB and make the search again.

The search try to bring the same rows, but it gives the error described below because an element of the rows doesn't exist.

Another thing is that the number of rows(var total) of the search is correct, but not the rows.

Here is a peace of my code:

ScrollableResults sr = query.scroll();
sr.last();
int total = sr.getRowNumber();
sr.close();

if (total >= 0)
{
query.setCacheable(true);
query.setFirstResult((getPagina() - 1) * 20);
query.setMaxResults(20);
}

return query.list();


I apreciate all the help!


Hibernate version:
2.1.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="br.trib.seg.persistencia.RegistroHistorico"
table="SEGREHREGISTRO_HISTORICO"
>

<id
unsaved-value="0"
name="idfRegHistorico"
type="long"
column="IDF_REG_HISTORICO"
>
<generator class="native">
<param name="sequence">SEQ_SEGREH1</param>
</generator>
</id>

<property
name="dtaCadastro"
type="java.sql.Timestamp"
column="DTA_CADASTRO"
not-null="true"
length="7"
/>
<property
name="nmeTabela"
type="java.lang.String"
column="NME_TABELA"
not-null="true"
length="30"
/>
<property
name="indOperacao"
type="byte"
column="IND_OPERACAO"
not-null="true"
length="2"
/>
<property
name="codChaveRegistro"
type="long"
column="COD_CHAVE_REGISTRO"
not-null="true"
length="10"
/>
<property
name="nmeTabelaPai"
type="java.lang.String"
column="NME_TABELA_PAI"
not-null="false"
length="30"
/>
<property
name="codChaveRegistroPai"
type="long"
column="COD_CHAVE_REGISTRO_PAI"
not-null="false"
length="10"
/>

<!-- associations -->
<!-- bi-directional many-to-one association to Segrecrecurso -->
<many-to-one
name="recurso"
class="br.trib.seg.persistencia.Acao"
not-null="true"
>
<column name="IDF_RECURSO" />
</many-to-one>
<!-- bi-directional one-to-many association to SegrhcregHistCampo -->
<bag
name="campos"
lazy="true"
inverse="false"
cascade="all-delete-orphan"
>
<key>
<column name="IDF_REG_HISTORICO" />
</key>
<one-to-many
class="br.trib.seg.persistencia.CampoHistorico"
/>
</bag>
<!-- bi-directional many-to-one association to Segusuusuario -->
<many-to-one
name="usuario"
class="br.trib.seg.persistencia.Usuario"
not-null="true"
>
<column name="IDF_USUARIO" />
</many-to-one>

</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 1, of class: br.trib.seg.persistencia.RegistroHistorico
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1918)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.assemble(EntityType.java:130)
at net.sf.hibernate.cache.QueryCache.get(QueryCache.java:76)
at net.sf.hibernate.loader.Loader.list(Loader.java:933)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at br.trib.app.util.Paginacao.recuperarLista(Paginacao.java:225)
at br.trib.seg.negocio.LogFactoryImpl.pesquisarAlteracoes(LogFactoryImpl.java:375)
at br.trib.seg.servico.SegFacadeImpl.pesquisarHistoricoAlteracoes(SegFacadeImpl.java:452)
at br.trib.seg.web.service.HistoricoProgramaService.pesquisarHistoricoAlteracoes(HistoricoProgramaService.java:264)
at br.trib.seg.web.action.HistoricoProgramaPesquisaAction.service(HistoricoProgramaPesquisaAction.java:95)
at br.trib.common.web.base.BaseAction.execute(BaseAction.java:132)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at br.trib.seg.saa.FiltroDeSeguranca.encadear(FiltroDeSeguranca.java:1129)
at br.trib.seg.saa.FiltroDeSeguranca.doFilterInterno(FiltroDeSeguranca.java:223)
at br.trib.app.filtro.FiltragemPorRequisicao.doFilter(FiltragemPorRequisicao.java:98)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
at br.trib.app.log.FiltroDeLog.doFilterInterno(FiltroDeLog.java:60)
at br.trib.app.filtro.FiltragemPorRequisicao.doFilter(FiltragemPorRequisicao.java:98)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)
at br.trib.app.sessao.SessionFilter.doFilterInterno(SessionFilter.java:128)
at br.trib.app.filtro.FiltragemPorRequisicao.doFilter(FiltragemPorRequisicao.java:98)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)
at br.trib.app.codificacao.FiltroDeCodificacao.doFilter(FiltroDeCodificacao.java:84)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:479)

Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
Hibernate: select registrohi0_.IDF_REG_HISTORICO as x0_0_ from SEGREHREGISTRO_HISTORICO registrohi0_, SEGHIRHIERARQUIA_RECURSO hierarquia1_, SEGHIRHIERARQUIA_RECURSO hierarquia2_, SEGHIRHIERARQUIA_RECURSO hierarquia3_, SEGUSUUSUARIO usuario4_ where (1=1 )and(registrohi0_.DTA_CADASTRO between ? and ? )and(usuario4_.IDF_LOTACAO=? and registrohi0_.IDF_USUARIO=usuario4_.IDF_USUARIO)and(usuario4_.IDF_USUARIO=? and registrohi0_.IDF_USUARIO=usuario4_.IDF_USUARIO)and(hierarquia1_.IDF_RECURSO_PAI=? )and(hierarquia2_.IDF_RECURSO_PAI=? )and(hierarquia3_.IDF_RECURSO_PAI=? )and(hierarquia1_.IDF_RECURSO_FILHO=hierarquia2_.IDF_RECURSO_PAI )and(hierarquia2_.IDF_RECURSO_FILHO=hierarquia3_.IDF_RECURSO_PAI )and(hierarquia3_.IDF_RECURSO_FILHO=registrohi0_.IDF_RECURSO )

Debug level Hibernate log excerpt:

_________________
Ricardo K. Costa


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 22, 2004 4:20 pm 
Beginner
Beginner

Joined: Tue Feb 10, 2004 8:22 am
Posts: 28
Oops...
I think it was:

query.setCacheable(true);

Sorry...

Att.,

_________________
Ricardo K. Costa


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.