gpt4 book ai didi

mysql - Liferay 6 不更新在 MySQL 中创建的自定义表

转载 作者:行者123 更新时间:2023-11-29 08:36:41 32 4
gpt4 key购买 nike

我正在使用 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

最佳答案

Have you created book table in mysql? if yes then mentioned it in service.xml file.
<?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" table="book">
<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>

关于mysql - Liferay 6 不更新在 MySQL 中创建的自定义表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15031923/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com