RE: Bind SQL View with Service Builder

Mayursinh Vaghela, modified 5 Years ago. New Member Posts: 5 Join Date: 10/17/19 Recent Posts
Hello All,I have create one mysql view in database to get data from multiple tables for reporting purpose.Now i want to bind that that view with service builder , so i have all interface and service to use it in my portlet.

Thanks Mayursinh
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
And?

The <entity /> block in service.xml doesn't know or care if it is actually pointing at a table or a view. You'll have to use the "table" attribute to point at your view name (otherwise SB will end up creating a table for the entity) and it must have a primary key (single column or compound is fine, just no dates).

But otherwise SB will generate code against it as though it is a table. You'll get full CRUD methods even though the database won't allow anything but the retrieve.

I would probably go an extra step and override all of the methods in the XxxLocalServiceImpl to throw an unsupported operation exception for all of the create, delete, and update methods just to ensure that no developer tries to invoke them (the DB would throw exceptions too, but why wait for the DB to tell you something that you already know is wrong.
Mayursinh Vaghela, modified 5 Years ago. New Member Posts: 5 Join Date: 10/17/19 Recent Posts
Thanks David for your extra suggestions.
it will help us lot.