<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Últimas mensagens do tópico "Consultas MUITO grandes com Hibernate e Oracle 8i"]]></title>
		<link>http://www.guj.com.br/posts/list/7.java</link>
		<description><![CDATA[Últimas mensagens enviadas no tópico "Consultas MUITO grandes com Hibernate e Oracle 8i"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Consultas MUITO grandes com Hibernate e Oracle 8i</title>
				<description><![CDATA[ Ola pessoal, <br /> estou num dilema danado, tenho uma aplicação que mostra no máximo, todos os varejos de uma determinada região, e isso se trata de 50.000 items em um result set, mas normalmente não chega aos 50.000, e sim aos 20.000<br /> Estou utilizando o Hibernate3, com o banco de dados Oracle, e para este tipo de consulta, tenho que fazer paginação, senão... Como vcs me aconselhariam fazer este tipo de paginação? Uma opção que estou implementando é utilizando ScrollableResults, atribuindo à ele o resultado de criteria.scroll, como segue:<br /> [code]<br /> ScrollableResults scrollableResults = query.scroll(ScrollMode.FORWARD_ONLY);<br /> List elements = criteria.setFirstResult(this.pageNumber * this.pageSize).setMaxResults(this.pageSize + 1).list();<br /> [/code]<br /> <br /> Só que desta maneira ele tb carrega os indices em memória, e inicializa somente os requeridos, retornando na segunda vez que executo um [b]OutOfMemoryException[/b].<br /> Alguém poderia me dizer uma maneira performática de implementar paginação com Oracle8i e Hibernate, para grandes massas de dados?<br /> <br /> Obrigado.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/25732/138564/consultas-muito-grandes-com-hibernate-e-oracle-8i
</guid>
				<link>http://www.guj.com.br/prepost/25732/138564/consultas-muito-grandes-com-hibernate-e-oracle-8i
</link>
				<pubDate><![CDATA[Thu, 9 Jun 2005 17:24:53]]> GMT</pubDate>
				<author><![CDATA[ Alexandre]]></author>
			</item>
			<item>
				<title>Re: Consultas MUITO grandes com Hibernate e Oracle 8i</title>
				<description><![CDATA[ Segue trecho do livro "Hibernate in Action", pág 205:<br /> <br /> "[b]Managing the first-level cache[/b]<br /> Consider this frequently asked question: ?I get an OutOfMemoryException when I try<br /> to load 100,000 objects and manipulate all of them. How can I do mass updates<br /> with Hibernate??<br /> It?s our view that ORM isn?t suitable for mass update (or mass delete) operations.<br /> If you have a use case like this, a different strategy is almost always better: call a<br /> stored procedure in the database or use direct SQL UPDATE and DELETE statements.<br /> Don?t transfer all the data to main memory for a simple operation if it can be performed<br /> more efficiently by the database. If your application is mostly mass operation<br /> use cases, ORM isn?t the right tool for the job!<br /> If you insist on using Hibernate even for mass operations, you can immediately<br /> evict() each object after it has been processed (while iterating through a query<br /> result), and thus prevent memory exhaustion.<br /> To completely evict all objects from the session cache, call Session.clear(). We<br /> aren?t trying to convince you that evicting objects from the first-level cache is a bad<br /> thing in general, but that good use cases are rare. Sometimes, using projection and<br /> 182 CHAPTER 5<br /> Transactions, concurrency, and caching<br /> a report query, as discussed in chapter 7, section 7.4.5, ?Improving performance<br /> with report queries,? might be a better solution.<br /> Note that eviction, like save or delete operations, can be automatically applied<br /> to associated objects. Hibernate will evict associated instances from the Session<br /> if the mapping attribute cascade is set to all or all-delete-orphan for a particular<br /> association.<br /> When a first-level cache miss occurs, Hibernate tries again with the second-level<br /> cache if it?s enabled for a particular class or association."<br /> <br /> Por outro lado vc poderia usar o "second-level cache", mais aparopriado para dados q são estáveis:<br /> <br /> "[b]The Hibernate second-level cache[/b]<br /> The Hibernate second-level cache has process or cluster scope; all sessions share<br /> the same second-level cache. The second-level cache actually has the scope of a<br /> SessionFactory.<br /> Persistent instances are stored in the second-level cache in a disassembled form.<br /> Think of disassembly as a process a bit like serialization (the algorithm is much,<br /> much faster than Java serialization, however).<br /> The internal implementation of this process/cluster scope cache isn?t of much<br /> interest; more important is the correct usage of the cache policies?that is, caching<br /> strategies and physical cache providers.<br /> Different kinds of data require different cache policies: the ratio of reads to<br /> writes varies, the size of the database tables varies, and some tables are shared with<br /> other external applications. So the second-level cache is configurable at the<br /> granularity of an individual class or collection role. This lets you, for example,<br /> enable the second-level cache for reference data classes and disable it for classes<br /> that represent financial records. The cache policy involves setting the following:<br /> &#9632; Whether the second-level cache is enabled<br /> &#9632; The Hibernate concurrency strategy<br /> &#9632; The cache expiration policies (such as timeout, LRU, memory-sensitive)<br /> &#9632; The physical format of the cache (memory, indexed files, cluster-replicated)<br /> Not all classes benefit from caching, so it?s extremely important to be able to disable<br /> the second-level cache. To repeat, the cache is usually useful only for readmostly<br /> classes. If you have data that is updated more often than it?s read, don?t<br /> enable the second-level cache, even if all other conditions for caching are true!<br /> Furthermore, the second-level cache can be dangerous in systems that share the<br /> database with other writing applications. As we explained in earlier sections, you<br /> must exercise careful judgment here.<br /> The Hibernate second-level cache is set up in two steps. First, you have to decide<br /> which concurrency strategy to use. After that, you configure cache expiration and<br /> physical cache attributes using the cache provider."<br /> <br /> Espero q isso ajude e que vc conclua postando a solução q acabou encontrando.<br /> <br /> Abraço.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/25732/138789/re-consultas-muito-grandes-com-hibernate-e-oracle-8i
</guid>
				<link>http://www.guj.com.br/prepost/25732/138789/re-consultas-muito-grandes-com-hibernate-e-oracle-8i
</link>
				<pubDate><![CDATA[Fri, 10 Jun 2005 11:24:40]]> GMT</pubDate>
				<author><![CDATA[ andre_salvati]]></author>
			</item>
			<item>
				<title>Re: Consultas MUITO grandes com Hibernate e Oracle 8i</title>
				<description><![CDATA[ Eu pensava que o Hibernate fazia a paginação com uma clausula SQL.<br /> Não é uma configuração ?<br /> ]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/25732/138899/re-consultas-muito-grandes-com-hibernate-e-oracle-8i
</guid>
				<link>http://www.guj.com.br/prepost/25732/138899/re-consultas-muito-grandes-com-hibernate-e-oracle-8i
</link>
				<pubDate><![CDATA[Fri, 10 Jun 2005 14:17:42]]> GMT</pubDate>
				<author><![CDATA[ jprogrammer]]></author>
			</item>
			<item>
				<title>Re: Consultas MUITO grandes com Hibernate e Oracle 8i</title>
				<description><![CDATA[ [code]<br /> Criteria c = session.createCriteria( ClaseQueTem2457MilhoesDeRegistros.class );<br /> c.setFirstResult( firstPageItem );<br /> c.setMaxResult( pageSize );[/code]<br /> Assim não resolve seu problema?]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/25732/138905/re-consultas-muito-grandes-com-hibernate-e-oracle-8i
</guid>
				<link>http://www.guj.com.br/prepost/25732/138905/re-consultas-muito-grandes-com-hibernate-e-oracle-8i
</link>
				<pubDate><![CDATA[Fri, 10 Jun 2005 14:21:40]]> GMT</pubDate>
				<author><![CDATA[ Filipe Sabella]]></author>
			</item>
	</channel>
</rss>
