Foren

Liferay EXT Plugins cannt set multiple datasource?

oxen C, geändert vor 11 Jahren.

Liferay EXT Plugins cannt set multiple datasource?

New Member Beiträge: 2 Beitrittsdatum: 02.03.12 Neueste Beiträge
Hi, all:
I use liferay ide to develop a portlet.
My portlet use multiple datasource, and liferay default datasource is "org.hibernate.dialect.MySQLDialect".
My portlet's datasource is "com.liferay.portal.dao.orm.hibernate.SQLServer2008Dialect".
But when app startup, occur error:

08:05:58,906 ERROR [JDBCExceptionReporter:75] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NVARCHAR(MAX)))) order by roleimpl0_.name ASC' at line 1
08:05:58,921 ERROR [PortalInstances:375] com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not execute query
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not execute query

If multiple datasource's dialect is the same, no problem.
I guess that liferay use SQLServer2008Dialect to do mysql's query.
Who can help me?
Very thanks!
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Liferay EXT Plugins cannt set multiple datasource?

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
If you're managing your hibernate stuff manually, you'll have to create your own hibernate session, etc., for handling this.

If you're using SB, there's a few extra steps you need to use. The SB entities need to be decorated with different attributes relevant to the sqlserver connection and create the custom beans in the ext-spring.xml file.
oxen C, geändert vor 11 Jahren.

RE: Liferay EXT Plugins cannt set multiple datasource?

New Member Beiträge: 2 Beitrittsdatum: 02.03.12 Neueste Beiträge
Thank, David H Nebinger!

=========================================
This is my service.xml:
<entity name="EmployeeInfo" table="account_" local-service="true" remote-service="false"
data-source="misDataSource" session-factory="misSessionFactory" tx-manager="misTransactionManager">
........
</entity>
=========================================
And this is my ext-spring.xml:
<bean id="misDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<bean class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/MisPool" />
</bean>
</property>
</bean>

<bean id="misHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortalHibernateConfiguration" lazy-init="true">
<property name="dataSource" ref="misDataSource" />
</bean>

<bean id="misSessionFactory" class="com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl">
<property name="sessionFactoryClassLoader">
<bean class="com.liferay.portal.kernel.util.PortalClassLoaderUtil" factory-method="getClassLoader" />
</property>
<property name="sessionFactoryImplementor" ref="misHibernateSessionFactory" />
</bean>

<bean id="misTransactionManager" class="com.liferay.portal.spring.transaction.TransactionManagerFactory" factory-method="createTransactionManager">
<constructor-arg ref="misDataSource" />
<constructor-arg ref="misHibernateSessionFactory" />
</bean>

<bean id="com.xxx.portlet.mis.service.EmployeeInfoLocalService" class="com.xxx.portlet.mis.service.impl.EmployeeInfoLocalServiceImpl" />

<bean id="com.xxx.portlet.mis.service.persistence.EmployeeInfoPersistence" class="com.xxx.portlet.mis.service.persistence.EmployeeInfoPersistenceImpl" parent="basePersistence">
<property name="dataSource" ref="misDataSource" />
<property name="sessionFactory" ref="misSessionFactory" />
</bean>
=========================================
Where is my problem?
Can you help me?
Very thanks!
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Liferay EXT Plugins cannt set multiple datasource?

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
Well first you don't need to do the EmployeeInfoLocalService bean or the EmployeeInfoPersistence bean as those are generated.

I don't think you need to override the transaction manager, as the standard one should work fine.

Otherwise you should be just fine. If not, you'll need to look at portlet-spring.xml to determine what is not set correctly for the persistence layer...