Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Last active November 21, 2022 05:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaeltuelho/e770d79521971138b756 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/e770d79521971138b756 to your computer and use it in GitHub Desktop.
Some Hibernate properties to use in your JPA persistence.xml descriptor
<!-- Hibenate JPA Provider -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_coments" value="true" />
<property name="hibernate.generate_statistics" value="true" />
<!-- Infinispan -->
<property name="hibernate.cache.infinispan.statistics" value="true" />
<property name="hibernate.cache.use_structured_entries" value="true" />
<!-- 2LC -->
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<!-- Hibenate Search (Apache Lucene) -->
<!-- property name="hibernate.search.default.directory_provider" value="filesystem" /-->
<property name="hibernate.search.default.directory_provider" value="infinispan" />
<property name="hibernate.search.default.worker.backend" value="jgroups" />
<property name="hibernate.search.default.indexBase" value="/tmp/lucene/index" />
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
@rafaeltuelho
Copy link
Author

The list of all possible Hibernate properties can be found in the Hibernate Core manual (Configuration section): http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch03.html

The Infinispan JPA-Hibernate Second Level Cache Provider: http://infinispan.org/docs/5.3.x/user_guide/user_guide.html#_using_infinispan_as_jpa_hibernate_second_level_cache_provider

@rafaeltuelho
Copy link
Author

To test JPA entities with Hibernate 2LC using Infinispan add

@Cacheable

to the entities.

To view JPA Persistence Unit runtime statistics use the following JBoss CLI commands:

/deployment=jboss-kitchensink.war/subsystem=jpa/hibernate-persistence-unit=jboss-kitchensink.war#primary/:read-resource(include-runtime=true)

To clean/flush the 2LC use the following JBoss CLI commands

/deployment=jboss-kitchensink.war/subsystem=jpa/hibernate-persistence-unit=jboss-kitchensink.war#primary:evict-all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment