Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
5.1 EE SP4 (5.1.7), 5.2 EE SP1 (5.2.5)
-
All
Description
Service builder automatically generates portlet-hbm.xml. The generated models use a specific model implementation. Sometimes plugin developers will want to subclass those implementations and use a custom model implementations instead. If a developer modifies portlet-hbm.xml and points their models to the new implementation, they lose their modifications next time service builder generates portlet-hbm.xml. This improvement is designed to address this issue.
To dynamically configure new classes, modify ext-spring.xml. For example:
<?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 configuration 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
- is related to
-
LPS-5363 Allow plugin developers to dynamically change portlet-hbm.xml before Hibernate reads it
- Closed