Interface HibernateIntegration

public interface HibernateIntegration

Integration with Hibernate

Smart GWT can integrate with Hibernate in two main ways, both of which are enabled by creating a DataSource descriptor (.ds.xml file) with serverType="hibernate":

Which mode to use is primarily a matter of preference and pre-existing code. However, if you do not have pre-existing code or other special circumstances, the following approach is the most productive:

  1. use "beanless" mode, specifying fields in Smart GWT's .ds.xml format (far more compact than a Java bean with a getter and setter for each field)
  2. add business logic as needed via DMI, Server Scripting, custom server validators, and other approaches covered in the QuickStart Guide
  3. call any reusable DMI methods both via your Smart GWT UI and via other, non-UI related Java logic (the DMI methods are now a reusable "data services tier")
  4. only create an actual Java bean if you discover re-usable, bean-specific business logic that cannot be encapsulated as a data service (rare)

Note that the Admin Console's "Import DataSources" section can be used to import test data into serverType:"hibernate" DataSources in the same manner as SQLDataSources.

HibernateDataSource supports operations with composite primary keys. Setting data source level property idClassName to fully qualified class name indicates, that entity uses composite primary key.

Hibernate relations

For Hibernate integration where Java beans have been explicitly declared, HibernateDataSource supports automatic handling of Hibernate relations that don't declare a concrete field to hold ID values - see JpaHibernateRelations.

Hibernate Configuration

You can provide Hibernate configuration to the Smart GWT server in three ways:

If you choose to have Smart GWT lookup the Hibernate configuration, and you specify a lookupStyle of "spring", Smart GWT will make use of a Hibernate SessionFactory configured by Spring. It is possible to set up multiple Hibernate configurations in Spring, and to map individual DataSources to different configurations by making use of the dataSource.configBean property mentioned above. Please note the following caveats:

Manual Hibernate Integration

In some cases you may not be able to immediately use the built-in HibernateDataSource - in this case take a look at manual Hibernate integration.