concept Service Builder in category liferay

This is an excerpt from Manning's book Liferay in Action: The Official Guide to Liferay Portal Development.
As far as standards go, Liferay is also based on widely used, standard ways of doing things. It adheres to the JSR-286 portlet standard. In addition to that, it includes utilities such as Service Builder to automatically generate interfaces to databases (something not covered by the standard). Under the hood, Service Builder is just Spring and Hibernate—widely used by Java developers everywhere. You get the benefit of using the platform to get your site done more quickly while taking advantage of standards that keep your code free.
But let’s go one step further. What if you could define a database table in an XML file and, from that definition, generate all the Hibernate configuration, all the Spring configuration, finder methods, the model layer, the SQL to create the table on all leading databases, and the entire Data Access Object (DAO) layer in one fell swoop? That’s what Service Builder gives you. Figure 3.4 illustrates this.
Just like adding and deleting, getting products out of the database is easy. You probably remember that you had Service Builder generate a finder that queries the database for products by the GroupId. You always want to query by groupId because the portlet is non-instanceable. You implement this in the DTO layer as follows:
This code returns a List of PRProducts that can be used in the UI layer to display products for viewing or editing purposes. And as you can see, whatever calls this method (it will be your portlet class) doesn’t need to know anything about JDBC or databases. It’s requesting a List. This frees you to do something like swap out Service Builder for something else without ever touching your portlet code.
You started with Product because it was a simple, standalone table. Now that you see how easy it is to use Service Builder, we can move on to looking at tables with relationships.
If you’re an experienced developer, it’s likely that you’ve dealt with a data-driven application before. Liferay ships with a tool called Service Builder that makes the creation of data-driven applications easy. I highly recommend that you use Service Builder when writing applications on Liferay’s platform, because it will help get you going quickly. How? By generating a lot of the database plumbing code for you, so you can concentrate on your application’s functionality.