掲示板

Service builder results not matching database values

11年前 に Ron J によって更新されました。

Service builder results not matching database values

Junior Member 投稿: 45 参加年月日: 12/11/18 最新の投稿
Hi everyone,

I've written a few portlets now using service builder, and all have worked wonderfully except for this last one. I have two entities; eventlist and events, one to many relationship. So I added some logic to the localserviceimpl method and reran service builder, entered some values into the db, and they're in my db if I look w/ psql. So now I'm testing and some of my simple finder methods don't return anything, they match the eventlist id which I grabbed from the db for testing purposes. Now if I use the findAll method, I get a bunch of entities, 13 to be exact although I only have one db entry for the eventlist table. So to get something working I was able to loop through the 13 results and use the newest inserted eventlist. When I now query for my events from that id, I get the correct number of results only their IDs don't match what's in the database, my values in the db are 10,11,12,13,14 but I see in my debug statements


events found by eventlistid : 5
eventId: 2306
eventId: 2307
eventId: 2308
eventId: 2309
eventId: 2310


After tons of experimentation I created a new LR instance to test on and now but didn't seem to make a difference. Anyone experience something similar?
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Service builder results not matching database values

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Liferay by default will use caching and lucene (sometimes) for entities getting persisted.

Have you tried reindexing all of the search indexes?
11年前 に Ron J によって更新されました。

RE: Service builder results not matching database values

Junior Member 投稿: 45 参加年月日: 12/11/18 最新の投稿
Yup, reindexed searches, cleared db cache, and cleared content caches.
11年前 に Ron J によって更新されました。

RE: Service builder results not matching database values

Junior Member 投稿: 45 参加年月日: 12/11/18 最新の投稿
I feel like I have create a new portlet and remake the services. If I modified my service.xml and changed some column names and types, would the old indexes and sql for those columns remain? Can I just delete all the service packages and jar, the sql folder, and drop all the tables in my db to get a 'fresh' service?
11年前 に Ron J によって更新されました。

RE: Service builder results not matching database values

Junior Member 投稿: 45 参加年月日: 12/11/18 最新の投稿
OK so I know what the problem is but not sure where or why it's the case. I followed a tutorial for connecting to an existing database, so in my portlet's ext-spring.xml I configured another database, but I did not reference the bean id anywhere in my project (I got it working then commented out refs). So now I just moved my dev to a different computer and I didn't have the tables in my db but if I connected to my external db it was grabbing those values...???? Where could it possibly keep this configuration?
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Service builder results not matching database values

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Oh, I see...

You have the datasource defined in ext-spring, but you didn't define the datasource for your entity reference. In this case, the SB code will create a table for the entity in the Liferay database. I'm sure that's happened in both environments now. If you check the Liferay database, you'll find a table "Namespace_Entity" where all of your values are located.

To use the external datasource, you have to add it to the xml definition of the entity. There's an attribute, datasource, which you set to be the bean name for the external datasource.

Build and redeploy the service and you'll see that you're now pulling the values from that datasource rather than the Liferay datasource.