Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
- Batch Index using Hibernate Search and Seam

- Batch Index using Hibernate Search and Seam

2007-11-01       - By mat

 Back
We need to index a large number of records using Hibernate Search;
Following the documentations and examples from SEAM, we have implemented the
followings. This is to eliminate Out Of Memory Exception and Timeout Exception
when indexing a large number of records.  
The method works fine (well, haven?t tested it with a large number yet) when it
is called from a stateful seam component (as the backing bean for use actions).
However, since this would be a long running process we need to add the
@(protected)  Adding this annotation stops the method after the EntityManager
call and log.info("EntityManager initilized."); is never called !
The persistence.xml has been modified for the specified batchSize as per
documentation.

Your help and feedback is highly appreciated;

Environment:

JBoss-4 (See http://oss-4.ora-code.com).2.1
SEAM-2 (See http://EAM-2.ora-code.com).0.CR1
RichFaces-3 (See http://ces-3.ora-code.com).1.2


 | @(protected)("indexManager")
 | public class IndexManagerBean {
 |
 |     @(protected)
 |     static Log log;
 |
 |     public int batchSize = 50;
 |
 |
 |     //@(protected)
 |     public void buildIndex(Class entityClass) {
 |         log.info("asynchronously rebuilding Lucene index for entity: " +
entityClass);
 |         EntityManager em = (EntityManager) Component.getInstance(
"entityManager");
 |         log.info("EntityManager initilized.");
 |         FullTextSession fullTextSession = (FullTextSession)em.getDelegate();
 |         fullTextSession.setFlushMode(FlushMode.MANUAL);
 |         fullTextSession.setCacheMode(CacheMode.IGNORE);
 |         org.hibernate.Transaction transaction = fullTextSession
.beginTransaction();
 |         //Scrollable results will avoid loading too many objects in memory
 |         ScrollableResults results = fullTextSession.createCriteria(
entityClass ).scroll( ScrollMode.FORWARD_ONLY);
 |         int index = 0;
 |         while( results.next() ) {
 |             index++;
 |             fullTextSession.index( results.get(0) ); //index each element
 |             if (index % batchSize == 0) fullTextSession.clear(); //clear
every batchSize since the queue is processed
 |         }
 |         transaction.commit();
 |
 |         try {
 |             if (results != null) results.close();
 |         } catch (Exception ex) {
 |             ex.printStackTrace();
 |         }
 |     }
 |
 | }
 |
 |

The entityManager is configured in the components.xml as:


 |     <persistence:filter name="accessCompanyFilter">
 |         <persistence:name>accessCompanyFilter</persistence:name>
 |         <persistence:parameters>
 |             <key>currentAccessCompany</key>
 |             <value>#{currentAccessCompany}</value>
 |         </persistence:parameters>
 |     </persistence:filter>    
 |            
 |     <persistence:managed-persistence-context name="entityManager"
 |                                       auto-create="true"
 |                                       entity-manager-factory="#
{TestEntityManagerFactory}"
 |                                       persistence-unit-jndi-name="java:/
TestEntityManagerFactory">                                                    
               
 |         <persistence:filters><value>#{accessCompanyFilter}</value><
/persistence:filters>                                          
 |     </persistence:managed-persistence-context>    
 |    
 |                                                              
 |      <persistence:managed-persistence-context name="gloabalEntityManager"
 |           auto-create="true"
 |           entity-manager-factory="#{TestEntityManagerFactory}"
 |           persistence-unit-jndi-name="java:/TestEntityManagerFactory">
 |     </persistence:managed-persistence-context>
 |
 |


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic
&p=4101028#4101028

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode
=reply&p=4101028
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user

©2008 junlu.com - Jax Systems, LLC, U.S.A.