public interface HibernateIntegration
serverType="hibernate"
:
schemaBean
to derive from the
bean or
autoDeriveSchema
to
derive from the mapping. In this case you will
initially have a very short .ds.xml per bean - no <fields> are required unless
and until you want to override the automatically derived fields.
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:
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.
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
.
You can provide Hibernate configuration to the Smart GWT server in three ways:
hibernate.cfg.xml
file somewhere on the
classpathConfiguration
to use. This
works in the same way as a ServerObject
, and in fact
makes use of the
ServerObject code, though note that lookupStyle "attribute" is not supported. To look
up a configuration, add ServerObject-compliant properties to your
server.properties
file, prefixed with
hibernate.config
. For
example: hibernate.config.lookupStyle: spring hibernate.config.bean: mySessionFactory
configBean
on the
dataSource (this is only
applicable if you are using Spring; see below)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:
.cfg.xml
file named in the Spring bean's configLocation
property, or by use of
persistence annotations in the actual mapped beans themselves
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
.