组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Ramon Ernesto Villen Souviron
ServiceBuilder with external DS - DS not being used in some cases?
2013年1月17日 上午4:18
答复

Ramon Ernesto Villen Souviron

等级: New Member

帖子: 2

加入日期: 2013年1月17日

最近的帖子

Hi,

we have developed an intranet portal using liferay-portal-6.1.1-ce-ga2. Requirements included the creation of a custom service to access our client's external database.

So, we created this service using ServiceBuilder, Manning "Liferay in Action" book as a guide and Liferay 6.1 API docs.

We have defined our custom datasource in src/META-INF/ext-spring.xml.
We stablished custom hibernateSessionFactory and TransactionManager, both referencing our custom datasource.
Then, we set our custom entities "DataSource", "Session Factory" and "Tx Manager" attributes to the ones defined in ext-spring.xml
Finally, we implemented custom Finders with custom SQL.

After building the service and deploying it (no errors or warnings) we notice that under certain circumstances our service uses Liferay default DS (accesing lportal), while the rest of the time our custom DS is used. We have identified the following scenarios where the described behaviour is consistent:

1) Jboss always deploys the database tables to 'lportal' instead of our custom DB.
2) when using a default LocalServiceUtil method, such as exampleLocalServiceUtil.getExamples(-1, -1) to get a full list of 'examples', the service looks in lportal database.
3) when using one of our custom Finder methods, such as customExampleLocalServiceUtil.getExamples(-1,1), the service looks up our 'custom' database.
4) when performing update operations using the service default methods, 'custom' database is used.

What could be causing this?
Thanks in advance
David H Nebinger
RE: ServiceBuilder with external DS - DS not being used in some cases?
2013年1月17日 上午8:58
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 11087

加入日期: 2006年9月1日

最近的帖子

If you add a service-ext.properties file, you can set build.auto.upgrade=false which will prevent the tables from being created in liferay's database.

As to why it may be using the LR datasource, not sure. When you say:

Then, we set our custom entities "DataSource", "Session Factory" and "Tx Manager" attributes to the ones defined in ext-spring.xml


I'm guessing that you actually meant that, in the service.xml file, your entities are defined like:

1 <entity ... data-source="myDataSource" session-factory="mySessionFactory" tx-manager="myTxnManager">...</entity>
Ramon Ernesto Villen Souviron
RE: ServiceBuilder with external DS - DS not being used in some cases?
2013年1月17日 上午9:56
答复

Ramon Ernesto Villen Souviron

等级: New Member

帖子: 2

加入日期: 2013年1月17日

最近的帖子

If you add a service-ext.properties file, you can set build.auto.upgrade=false which will prevent the tables from being created in liferay's database.


Added this now, thanks!

I'm guessing that you actually meant that, in the service.xml file, your entities are defined like: ...


Yep, that's what I meant.

Thanks!
Chris Tophe
RE: ServiceBuilder with external DS - DS not being used in some cases?
2013年2月13日 上午6:22
答复

Chris Tophe

等级: New Member

帖子: 1

加入日期: 2013年2月1日

最近的帖子

Hello,

I tried to use custom sql with custom DS. I only change references to Datasource in ext-spring.xml but I use the default SessionFactory and transaction tx beacause I can't find on the net a description of how to do to customize these objects.

My configuration works when I use service buildes standard methods (with the external database) but When I want to use custom sql I have an error (the bean names with my datasource can't be created).


Is ther somewher a description of how to configure Liferay to do custom sql on external DS ?

Thanks a lot
Christophe