掲示板
Liferay 6: query with Liferay ServiceBuilder
12年前 に Ravi Kiran によって更新されました。
Liferay 6: query with Liferay ServiceBuilder
Junior Member 投稿: 98 参加年月日: 11/12/12 最新の投稿
I am using MYSQL 5 in Liferay by specyfying Databse properties inside portal-ext.properties .
I am unsuccessful with ServiceBuilder . Data is not being inserted inside Database .
This is my service.xml
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com">
<namespace>Library</namespace>
<entity name="Book" local-service="true" remote-service="false">
<column name="bookId" type="String" primary="true" />
<column name="companyId" type="String" />
<column name="userId" type="String" />
</entity>
</service-builder>
I ran ServiceBuilder , it generated the java files . From my Struts Action class
public String execute() throws Exception {
HttpServletRequest req = getActionRequest();
String name = ParamUtil.getString(req, "name");
String password = ParamUtil.getString(req, "password");
Book book = new BookImpl();
book.setBookId("cc");
book.setUserId("ss");
book.setCompanyId("cid");
BookLocalServiceUtil.addBook(book);
return ActionSupport.SUCCESS;
}
I only modifyig the Struts Action class and did not touch any Liferay generated class Do i need to modify any java class ??
Thank you for reading .
I am unsuccessful with ServiceBuilder . Data is not being inserted inside Database .
This is my service.xml
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com">
<namespace>Library</namespace>
<entity name="Book" local-service="true" remote-service="false">
<column name="bookId" type="String" primary="true" />
<column name="companyId" type="String" />
<column name="userId" type="String" />
</entity>
</service-builder>
I ran ServiceBuilder , it generated the java files . From my Struts Action class
public String execute() throws Exception {
HttpServletRequest req = getActionRequest();
String name = ParamUtil.getString(req, "name");
String password = ParamUtil.getString(req, "password");
Book book = new BookImpl();
book.setBookId("cc");
book.setUserId("ss");
book.setCompanyId("cid");
BookLocalServiceUtil.addBook(book);
return ActionSupport.SUCCESS;
}
I only modifyig the Struts Action class and did not touch any Liferay generated class Do i need to modify any java class ??
Thank you for reading .
12年前 に Juhi Kumari によって更新されました。
RE: Liferay 6: query with Liferay ServiceBuilder
Expert 投稿: 347 参加年月日: 11/12/12 最新の投稿
Hi
In BookLocalServiceImpl class you need to write this method.
public Book addBook(Book book) throws SystemException{
return bookPersistence.update(book, false);
}
Then again run
ant build-service
Now you can use this method in your action class using BookLocalServiceUtil class.
Regards
Juhi
In BookLocalServiceImpl class you need to write this method.
public Book addBook(Book book) throws SystemException{
return bookPersistence.update(book, false);
}
Then again run
ant build-service
Now you can use this method in your action class using BookLocalServiceUtil class.
Regards
Juhi
12年前 に Ravi Kiran によって更新されました。
RE: Liferay 6: query with Liferay ServiceBuilder
Junior Member 投稿: 98 参加年月日: 11/12/12 最新の投稿
Thank you its working now .
What i have done is , added the custom method in ---LocalServiceUtil .
Added the same method inside --LocalServiveImple (Removed the static keyword Method ) and added
return ---LocalServiceUtil.method name
Its working .
What i have done is , added the custom method in ---LocalServiceUtil .
Added the same method inside --LocalServiveImple (Removed the static keyword Method ) and added
return ---LocalServiceUtil.method name
Its working .