Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Ramon Ernesto Villen Souviron
ServiceBuilder with external DS - DS not being used in some cases?
17. Januar 2013 04:18
Antwort

Ramon Ernesto Villen Souviron

Rang: New Member

Nachrichten: 2

Eintrittsdatum: 17. Januar 2013

Neue Beiträge

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?
17. Januar 2013 08:58
Antwort

David H Nebinger

Rang: Liferay Legend

Nachrichten: 6693

Eintrittsdatum: 1. September 2006

Neue Beiträge

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?
17. Januar 2013 09:56
Antwort

Ramon Ernesto Villen Souviron

Rang: New Member

Nachrichten: 2

Eintrittsdatum: 17. Januar 2013

Neue Beiträge

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?
13. Februar 2013 06:22
Antwort

Chris Tophe

Rang: New Member

Nachrichten: 1

Eintrittsdatum: 1. Februar 2013

Neue Beiträge

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