This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Hibernate - Core - Conf

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed bad links due to copy-paste from cwiki-test
Wiki Markup
{contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=TAPESTRY|labels=hibernate}

Configuring Hibernate

The Tapestry Hibernate Library is responsible for configuring Hibernate for youHibernate Configuration is handled by the Tapestry Hibernate Core module. This is done in a just-in-time manner, the first time a Hibernate Session is required.

titleRelated Articles
Content by Label
titleRelated Articles
cqllabel = "hibernate" and space = currentSpace()

HibernateSessionSource Configuration

One way to configure hibernate is to create a hibernate.cfg.xml file and place it in the root of your application (i.e., under src/main/resources). Most Hibernate-specific configuration occurs in this file. Another way is to contribute objects that perform configuration (such as setting event listeners). Example:

Code Block

public static void contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer> config)
  config.add("Widget", new WidgetHibernateConfigurer());


  • Default - performs default hibernate configuration
  • PackageName - loads entities by package name as contributed to the HibernateEntityPackageManager service

HibernateEntityPackageManager Configuration

This configuration is a set of package names, identifying where to search for entity classes.


By default, the package application-root-package.entities is scanned as described above. If you have additional packages containing entities, you must contribute them to the tapestry.hibernate.HibernateEntityPackageManager service configuration.


Code Block
languagejava (partial)

public static void contributeHibernateEntityPackageManager(Configuration<String> configuration)


The Hibernate integration includes a number of symbols used to control certain features:




If true (the default) then ValueEncoders are automatically provided for all Hibernate entities (ValueEncoders are used to encode the primary keys of entities as strings that can be included in URLs). Set to false if you want direct control over this feature.




If true (the default), then the application must include a hibernate.cfg.xml file. If your application configures itself entirely in code, you should set this symbol to false.


If "true", the Hibernate is initialized when the application starts up. The default is "false", to start Hibernate up lazily, on first use.