openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darren Senel <darren.se...@gmail.com>
Subject Re: Memory Usage
Date Mon, 29 Jun 2009 15:24:14 GMT

Hello Pinaki,

We declare the persistent domain classes in persistence.xml.  Here is our
persistence.xml content:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
  <persistence-unit name="active">
   
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>  
    <jta-data-source>com.pwc.us.wcps.ds.WCPS_ACTIVE_DS</jta-data-source> 
   
<non-jta-data-source>com.pwc.us.wcps.ds.WCPS_ACTIVE_DS</non-jta-data-source> 
  
  	<class>com.pwc.us.wcps.dto.BaseContentDTO</class>	
  	<class>com.pwc.us.wcps.dto.ConfigDTO</class>	  	
  	<class>com.pwc.us.wcps.dto.PrimaryContentDTO</class>  
  	<class>com.pwc.us.wcps.dto.lists.RepeatedAttribute</class>
  	<class>com.pwc.us.wcps.dto.DynamicCollectionDTO</class>
  	<class>com.pwc.us.wcps.translations.VTranslationDTO</class>	    
  	<class>com.pwc.us.wcps.translations.TranslationDTO</class>	
  	<class>com.pwc.us.wcps.translations.SubgroupDTO</class>	
  	<class>com.pwc.us.wcps.translations.GroupDTO</class>
  	<class>com.pwc.us.wcps.dto.TerritoryDTO</class>	  
  	<class>com.pwc.us.wcps.dto.FriendlyURLDTO</class>	
  	<class>com.pwc.us.wcps.taxonomy.TaxonomyDTO</class>	 
  	<class>com.pwc.us.wcps.dto.MigrationMasterDTO</class>
    <properties>
	  <property name="openjpa.TransactionMode" value="managed"/>
	  <property name="openjpa.ConnectionFactoryMode" value="managed"/>      
      <property name="openjpa.jdbc.DBDictionary"
value="org.apache.openjpa.jdbc.sql.OracleDictionary"/>
      <property name="openjpa.Log" value="DefaultLevel=ERROR, Tool=FATAL,
SQL=FATAL"/>
      <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
    </properties>
  </persistence-unit>    
</persistence>

For each request we create an instance of one of the persistent classes as
follows:

PrimaryContentDTO primaryContent = new PrimaryContentDTO();

And then we load from the database using a primary key:

                emf = WCPSUtils.getEMF();
		
                // Set primary key
		BaseContentDTOPk pk = new BaseContentDTOPk();
		pk.setA_webc_url(this.path);
		pk.setI_full_format("jhtml");
		pk.setLanguage_code(this.getLocaleOverride());

		// Load from database
		EntityManager em = emf.createEntityManager();
		try {
			PrimaryContentDTO temp = em.find(this.getClass(), pk);

			// Need to merge returned values with this object
			if (temp != null)
				merge(temp);

			if (log.isDebugEnabled()) {
				log.debug("Begin loadFromDB()");
			}
			
		} finally {
			em.close();
			em = null;
		}


The WCPSUtils class returns the singleton instance of the
EntityManagerFactory.

We have an inheritance hierarchy for most of the persistent classes. But the
one above follows this hierarchy:

BaseContentDTO -> ConfigDTO -> PrimaryContentDTO

BaseContentDTO has a one-to-many relationship to RepeatedAttribute
persistent class. We are eagerly fetching everything.  We only do reads from
the database, we have no inserts or updates.

I believe all the classes will be loaded using the same web application
class loader in WebSphere AppServer.

Hope this is the information you needed to help us analyze this issue.  Your
help is really appreciated.

Thanks,

Darren


Pinaki Poddar wrote:
> 
> Hi,
>   Having a single instance of EntityManagerFactory and making it live for
> the entire application lifetime is a good practice. Can you tell us how
> the persistent domain classes for are being specified (and loaded) for the
> application? 
>   For example, do you declare them in <class> clause of persistence.xml?
> Or in a orm.xml file? 
> Or are they not declared at all explicitly and loaded dynamically by the
> application? 
> Also is the application using multiple classloaders to load these classes?
> 
>   The container in PCRegistry that has occupied so much memory in the
> described profile is used to hold persistent domain class information.
> Knowing the classloading behavior of the application will help diagnosis.
>  
> 
> 

-- 
View this message in context: http://n2.nabble.com/Memory-Usage-tp3166851p3175091.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message