[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - second level cache

loic do-not-reply at jboss.com
Wed Nov 14 14:28:27 EST 2007


Hi All,

I'm using EJB3 on jboss4.0.5.GA connected on MSSQLServer using jtds.

Everything's going well instead a problem on cache.

Here is the test i'm doing :

I have a sample entity :

@Entity
  | @Table(name="FileToSend")
  | public class FileToSend 

And i'm using it in a stateful session bean where I use a fonction to test cache

  | @Stateful
  | public class FileToSendBean implements RemoteFileToSend 
  | 



public void findAll() {
  | 		// TODO Auto-generated method stub
  | 		for(int i=0;i<6;i++){
  | 	  			  		em.createQuery("SELECT c FROM FileToSend c").getResultList();
  | 		}
  | 	}


I am calling it threw a fonction in a servlet :


ctx = new InitialContext();			 
  | fileToSendService= (RemoteFileToSend) ctx.lookup("FileToSendBean/remote");
  |     		  		
  |  for(int i=0;i<6;i++){	  		
  | fileToSendService.findAll();
  | }



Each call to the findAll fonction is well done and i get the results each time.

But The matter that i have is that the request is processed each time on SQL Server.

I think if i'm not crazy that launching several times the same query doesn't need to get the information in SQL server but in the cache, isn't it?

So I think I'm missing something... please help!!


Here is the log i got when starting my ejb ... all seems well to me.. and second level cache is enable :

2007-11-14 19:23:27,437 INFO  [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: persistence.units:jar=ejbsupplier.jar,unitName=edieyessupplier with dependencies:
2007-11-14 19:23:27,437 INFO  [org.jboss.ejb3.JmxKernelAbstraction] 	jboss.jca:name=TestDS,service=DataSourceBinding
2007-11-14 19:23:27,453 INFO  [org.hibernate.ejb.Ejb3Configuration] Processing PersistenceUnitInfo [
	name: edieyessupplier
	...]
2007-11-14 19:23:27,453 INFO  [org.hibernate.ejb.Ejb3Configuration] found EJB3 Entity bean: com.edieyes.supplier.ejb3.entities.FileToSend
2007-11-14 19:23:27,468 WARN  [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
2007-11-14 19:23:27,468 INFO  [org.hibernate.cfg.Configuration] Reading mappings from resource: META-INF/orm.xml
2007-11-14 19:23:27,531 INFO  [org.hibernate.ejb.Ejb3Configuration] [PersistenceUnit: edieyessupplier] META-INF/orm.xml found
2007-11-14 19:23:27,546 INFO  [org.hibernate.cfg.AnnotationBinder] Binding entity from annotated class: com.edieyes.supplier.ejb3.entities.FileToSend
2007-11-14 19:23:27,546 INFO  [org.hibernate.cfg.annotations.EntityBinder] Bind entity com.edieyes.supplier.ejb3.entities.FileToSend on table FileToSend
2007-11-14 19:23:27,562 INFO  [org.hibernate.connection.ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2007-11-14 19:23:27,578 INFO  [org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider] Using provided datasource
2007-11-14 19:23:27,578 INFO  [org.hibernate.cfg.SettingsFactory] RDBMS: Microsoft SQL Server, version: 08.00.0194
2007-11-14 19:23:27,578 INFO  [org.hibernate.cfg.SettingsFactory] JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2.2
2007-11-14 19:23:27,578 INFO  [org.hibernate.dialect.Dialect] Using dialect: org.hibernate.dialect.SQLServerDialect
2007-11-14 19:23:27,578 INFO  [org.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
2007-11-14 19:23:27,578 INFO  [org.hibernate.transaction.TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
2007-11-14 19:23:27,578 INFO  [org.hibernate.transaction.TransactionManagerLookupFactory] instantiated TransactionManagerLookup
2007-11-14 19:23:27,578 INFO  [org.hibernate.cfg.SettingsFactory] Automatic flush during beforeCompletion(): disabled
2007-11-14 19:23:27,578 INFO  [org.hibernate.cfg.SettingsFactory] Automatic session close at end of transaction: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Scrollable result sets: enabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] JDBC3 getGeneratedKeys(): enabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Connection release mode: auto
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Default batch fetch size: 1
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Generate SQL with comments: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Order SQL updates by primary key: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2007-11-14 19:23:27,593 INFO  [org.hibernate.hql.ast.ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Query language substitutions: {}
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] JPA-QL strict compliance: enabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Second-level cache: enabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Query cache: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Optimize cache for minimal puts: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Structured second-level cache entries: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Statistics: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Deleted entity synthetic identifier rollback: disabled
2007-11-14 19:23:27,593 INFO  [org.hibernate.cfg.SettingsFactory] Default entity-mode: pojo
2007-11-14 19:23:27,609 INFO  [org.hibernate.impl.SessionFactoryImpl] building session factory
2007-11-14 19:23:27,625 INFO  [org.hibernate.impl.SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
2007-11-14 19:23:27,625 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] Running hbm2ddl schema update
2007-11-14 19:23:27,625 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] fetching database metadata
2007-11-14 19:23:27,625 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] updating schema
2007-11-14 19:23:27,656 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] table found: optixml2.dbo.FileToSend
2007-11-14 19:23:27,656 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] columns: [typecommunication, sendrdf, nomfile, sendhourbegin, sujet, sendhourend, mqueuename, otherfile, attach, dest, id]
2007-11-14 19:23:27,656 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] foreign keys: []
2007-11-14 19:23:27,656 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] indexes: [pk__filetosend__1cbc4616]
2007-11-14 19:23:27,656 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] schema update complete
2007-11-14 19:23:27,656 INFO  [org.hibernate.util.NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
2007-11-14 19:23:27,656 INFO  [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=ejbsupplier.jar,name=FileToSendBean,service=EJB3 with dependencies:
2007-11-14 19:23:27,656 INFO  [org.jboss.ejb3.JmxKernelAbstraction] 	persistence.units:jar=ejbsupplier.jar,unitName=edieyessupplier
2007-11-14 19:23:27,687 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: com.edieyes.supplier.ejb3.sessions.FileToSendBean ejbName: FileToSendBean
2007-11-14 19:23:27,703 INFO  [org.jboss.ejb3.cache.simple.SimpleStatefulCache] Initializing SimpleStatefulCache with maxSize: 100000 timeout: 300 for jboss.j2ee:jar=ejbsupplier.jar,name=FileToSendBean,service=EJB3
2007-11-14 19:23:27,703 INFO  [org.jboss.ejb3.EJB3Deployer] Deployed: file:/C:/jboss-4.0.5.GA/server/all/deploy/ejbsupplier.jar


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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104747



More information about the jboss-user mailing list