2.8.3. Registering custom annotated classes and Hibernate XML files into the service

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

It is possible to use the eXo Hibernate service and register your annotated classes or Hibernate hbm.xml files to leverage some add-on features of the service, such as the table automatic creation and the cache of the hibernate session in a ThreadLocal object during the whole request lifecycle. To do so, you just have to add a plugin and indicate the location of your files.

Registering custom XML files


<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration>
  <external-component-plugins>
    <target-component>org.exoplatform.services.database.HibernateService</target-component>
    <component-plugin>
      <name>add.hibernate.mapping</name>
      <set-method>addPlugin</set-method>
      <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
      <init-params>
        <values-param>
          <name>hibernate.mapping</name>
          <value>org/exoplatform/services/organization/impl/UserImpl.hbm.xml</value>
          <value>org/exoplatform/services/organization/impl/MembershipImpl.hbm.xml</value>
          <value>org/exoplatform/services/organization/impl/GroupImpl.hbm.xml</value>
          <value>org/exoplatform/services/organization/impl/MembershipTypeImpl.hbm.xml</value>
          <value>org/exoplatform/services/organization/impl/UserProfileData.hbm.xml</value>
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>
</configuration>

Registering custom annotated classes


<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration>
  <external-component-plugins>
    <target-component>org.exoplatform.services.database.HibernateService</target-component>
    <component-plugin>
      <name>add.hibernate.annotations</name>
      <set-method>addPlugin</set-method>
      <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
      <init-params>
        <values-param>
          <name>hibernate.annotations</name>
          <value>org.exoplatform.services.organization.impl.UserProfileData</value>
          <value>org.exoplatform.services.organization.impl.MembershipImpl</value>
          <value>org.exoplatform.services.organization.impl.GroupImpl</value>
          <value>org.exoplatform.services.organization.impl.MembershipTypeImpl</value>
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>
</configuration>
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus