quarta-feira, 19 de dezembro de 2007

persistence.xml Hibernate JPA

Abaixo o persistence.xml para usar Hibernate com JPA no JBoss com Datasource.

<persistence-unit name="jpaPU">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/DerbyDS</jta-data-source>
<class>com.jboss.entities.Country</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
</properties>
</persistence-unit>
JBoss já disponibiliza uma série de propriedades pré-configuradas para o uso de JPA com Hibernate no arquivo /server/default/deploy/ejb3.deployer/META-INF/persistence.properties. Você pode usa-lo para ter uma idéia das propriedades que poderão ser sobrescritas no seu persistence.xml.

Segue a lista abaixo:
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
#hibernate.connection.release_mode=after_statement
#hibernate.transaction.flush_before_completion=false
#hibernate.transaction.auto_close_session=false
#hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
#hibernate.hbm2ddl.auto=create-drop
#hibernate.hbm2ddl.auto=create
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
# Clustered cache with TreeCache
#hibernate.cache.provider_class=org.jboss.ejb3.entity.TreeCacheProviderHook
#hibernate.treecache.mbean.object_name=jboss.cache:service=EJB3EntityTreeCache
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.jndi.java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
hibernate.jndi.java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
hibernate.bytecode.use_reflection_optimizer=false
# I don't think this is honored, but EJB3Deployer uses it
hibernate.bytecode.provider=javassist

Nenhum comentário: