我正在使用 Liferay 6.1
我在 mysql 中创建了一个表,如图所示
create table Book (
bookId bigint(10) not null primary key,
companyId bigint(10) null ,
userId bigint(10) null ,
userName VARCHAR(75)
);
这是我的 service.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<service-builder package-path="com.test">
<author>sai</author>
<namespace>Library</namespace>
<entity name="Book" local-service="true" remote-service="false">
<column name="bookId" type="long" primary="true" />
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
</entity>
</service-builder>
这是我的 BookLocalServiceImpl 类
public class BookLocalServiceImpl extends BookLocalServiceBaseImpl {
public Book addBook(long userId, String userName) throws PortalException,
SystemException {
long bookId = CounterLocalServiceUtil.increment(Book.class.getName());
Book book = bookPersistence.create(bookId);
book.setCompanyId(1126);
book.setUserId(1126);
book.setUserName(title);
book = bookPersistence.update(book, false);
return book;
}
}
在 processAction 类中,我添加了这种方式
BookLocalServiceUtil.addBook(userId, userName);
但问题是,Liferay 框架创建了一个名为 library_book 的新表并更新了该表。
mysql> select * from library_book;
+--------+-----------+--------+----------+
| bookId | companyId | userId | userName |
+--------+-----------+--------+----------+
| 1 | 1126 | 1126 | saibaba |
+--------+-----------+--------+----------+
1 row in set (0.00 sec)
我的表书是空的
mysql> select * from Book;
Empty set (0.00 sec)
请让我知道如何使表格 Book 得到更新,但不是 library_book