Wiki Markup |
---|
{float:right|background=#eee}
{contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=TAPESTRY|labels=hibernate}
{float} |
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.
Div |
---|
style | float:right |
---|
title | Related Articles |
---|
class | aui-label |
---|
|
Content by Label |
---|
showLabels | false |
---|
showSpace | false |
---|
title | Related Articles |
---|
cql | label = "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());
} |
...
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.
Example:
Code Block |
---|
language | java |
---|
firstline | AppModule.java (partial) |
---|
|
public static void contributeHibernateEntityPackageManager(Configuration<String> configuration)
{
configuration.add("org.example.myapp.domain");
} |
...