Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-5363

Allow plugin developers to dynamically change portlet-hbm.xml before Hibernate reads it

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 5.1.2, 5.2.3
    • None
    • None
    • None
    • 5.2.x, 5.1.x
    • Committed

    Description

      ServiceBuilder automatically generates portlet-hbm.xml

      The generated models use a specific model implementation. Sometimes plugin developers will want to subclass those implementations and use their model implementations instead. If they modify portlet-hbm.xml and point their models to the new implementation, then they lose their modifications next time they regenerate.

      To dynamically configure new classes, modify ext-spring.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <beans
      xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
      >
      <bean id="liferayHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration">
      <property name="dataSource" ref="liferayDataSource" />
      <property name="hibernateConfigurationConverter" ref="liferayHibernateConfigurationConverter" />
      </bean>
      <bean id="liferayHibernateConfigurationConverter" class="com.liferay.portal.spring.hibernate.HibernateConfigurationConverter">
      <property name="classNames">
      <map key-type="java.lang.String" value-type="java.lang.String">
      <entry key="com.sample.model.FooImpl" value="com.sample.model.MyFooImpl" />
      </map>
      </property>
      </bean>
      </beans>

      This configuraiton will change com.sample.model.FooImpl in portlet-hbm.xml to com.sample.model.MyFooImpl.

      Suppose you want to do something even less predictable, simply set:

      <bean id="liferayHibernateConfigurationConverter" class="YOUROWNCLASSHERE">

      The liferayHibernateConfigurationConverter bean must implement com.liferay.portal.kernel.util.Converter<String>

      Attachments

        Issue Links

          Activity

            People

              support-lep@liferay.com SE Support
              brian.chan Brian Chan
              Kiyoshi Lee Kiyoshi Lee
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                13 years, 9 weeks, 2 days ago

                Packages

                  Version Package