掲示板
Service Builder is not generating annotations in LocalService interface
8年前 に Fernando Cabrera によって更新されました。
Service Builder is not generating annotations in LocalService interface
Junior Member 投稿: 47 参加年月日: 14/08/01 最新の投稿
Hello
I'm having troubles implementing transaction for my addEntity custom method declared in EntityLocalServiceImpl class, after put the Transactional annotation and run the liferay:buil-service command the EntityLocalService interface has no changes, it is not adding the annotations, also i try with anotther annotations like Deprecated.
Simplified entity declared in service.xml:
ext-spring.xml (database is Oracle XE 11)
ComponenteLocalServiceImpl.java
When run the code the rollback is not working. It is supposed to works even without the annotation because the method name starts with add. I have tried even the <tx-required>addComponente</tx-required> in the <entity> element.
Any idea? Do you need that I included more information?
Thank you.
I'm having troubles implementing transaction for my addEntity custom method declared in EntityLocalServiceImpl class, after put the Transactional annotation and run the liferay:buil-service command the EntityLocalService interface has no changes, it is not adding the annotations, also i try with anotther annotations like Deprecated.
Simplified entity declared in service.xml:
<entity name="Componente" uuid="true" local-service="true" remote-service="false" cache-enabled="false" data-source="consolaDataSource" session-factory="consolaSessionFactory" tx-manager="consolaTransactionManager">
<column name="idComponente" type="long" primary="true" />
<column name="nombre" type="String" />
<column name="tipo" type="boolean" />
</entity>
ext-spring.xml (database is Oracle XE 11)
<!--?xml version="1.0"?-->
<beans>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/jdbc.properties</value>
</property>
</bean>
<bean id="consolaDataSourceTarget" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.consola.driverClassName}" />
<property name="url" value="${jdbc.consola.url}" />
<property name="username" value="${jdbc.consola.username}" />
<property name="password" value="${jdbc.consola.password}" />
</bean>
<bean id="consolaDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<ref bean="consolaDataSourceTarget" />
</property>
</bean>
<bean id="consolaHibernateSessionFactory" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil" factory-method="newBean">
<constructor-arg value="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration" />
<constructor-arg>
<map>
<entry key="dataSource" value-ref="consolaDataSource" />
</map>
</constructor-arg>
</bean>
<bean id="consolaSessionFactory" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil" factory-method="newBean">
<constructor-arg value="com.liferay.portal.dao.orm.hibernate.PortletSessionFactoryImpl" />
<constructor-arg>
<map>
<entry key="dataSource" value-ref="consolaDataSource" />
<entry key="sessionFactoryClassLoader" value-ref="portletClassLoader" />
<entry key="sessionFactoryImplementor" value-ref="consolaHibernateSessionFactory" />
</map>
</constructor-arg>
</bean>
<bean id="consolaTransactionManager" class="com.liferay.portal.kernel.util.InfrastructureUtil" factory-method="getTransactionManager" />
</beans>
ComponenteLocalServiceImpl.java
public class ComponenteLocalServiceImpl extends ComponenteLocalServiceBaseImpl {
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Componente addComponente(Componente newComponente, long userId,
ServiceContext serviceContext) throws SystemException, PortalException {
long idComponente = counterLocalService.increment();
Componente componente = componentePersistence.create(idComponente);
componente.setNombre(newComponente.getNombre());
componente.setTipo(newComponente.getTipo());
componentePersistence.update(componente);
if (componente.isTipo()) {
throw new SystemException();
} else if (!componente.isTipo()) {
throw new PortalException();
}
return componente;
}
}
When run the code the rollback is not working. It is supposed to works even without the annotation because the method name starts with add. I have tried even the <tx-required>addComponente</tx-required> in the <entity> element.
Any idea? Do you need that I included more information?
Thank you.