Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Bind SQL View with Service Builder
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
Thanks Mayursinh
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.
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.
Thanks David for your extra suggestions.
it will help us lot.
it will help us lot.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™