Forums

Home » Liferay IDE » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
oxen C
Liferay EXT Plugins cannt set multiple datasource?
April 26, 2012 1:24 AM
Answer

oxen C

Rank: New Member

Posts: 2

Join Date: March 2, 2012

Recent Posts

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!
David H Nebinger
RE: Liferay EXT Plugins cannt set multiple datasource?
April 26, 2012 8:04 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6126

Join Date: September 1, 2006

Recent Posts

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
RE: Liferay EXT Plugins cannt set multiple datasource?
April 26, 2012 7:32 PM
Answer

oxen C

Rank: New Member

Posts: 2

Join Date: March 2, 2012

Recent Posts

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!
David H Nebinger
RE: Liferay EXT Plugins cannt set multiple datasource?
April 27, 2012 9:31 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6126

Join Date: September 1, 2006

Recent Posts

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...