3

我正在从 Liferay 7.2 移植到 Liferay 7.3.6 GA7。我有一个自定义表。当我使用 ..LocalServiceUtil 添加第一行时,没关系。但是以后每次我使用持久性(例如tablePersistence.update(table);)都会失败并且liferay会抛出:

错误 [http-nio-8080-exec-1][ExceptionMapper:31] java.lang.NullPointerException java.lang.NullPointerException at com.liferay.portal.cache.internal.dao.orm.FinderCacheImpl._getArguments(FinderCacheImpl.java: 466) 在 com.liferay.portal.cache.internal.dao.orm.FinderCacheImpl.updateByEntityCache(FinderCacheImpl.java:378) 在 com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl._putResult(EntityCacheImpl.java: 439) 在 com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl.putResult(EntityCacheImpl.java:336) 在 com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl.putResult(EntityCacheImpl.java:第358章)在com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl.putResult(EntityCacheImpl.java:328)

尝试执行 entityCache.putResult(entityCacheEnabled,...); 时,例外情况在 ..PersistenceImpl 中。我不明白我是否在移植过程中丢失了某些东西,或者是否在 7.3 中丢失了某些东西。

这是一个在 customTable 中添加行的方法的示例,并且fooPersistence.update(foo)在第一次之后抛出异常:

@Indexable(type = IndexableType.REINDEX) 
public Foo add(ServiceContext serviceContext) 
throws PortalException { 
   long companyId = serviceContext.getCompanyId(); 
   long userId = serviceContext.getUserId(); 
   User user = UserLocalServiceUtil.getUser(userId); 
   long groupId = user.getGroupId(); 
   long id = counterLocalService.increment(); 
   Foo foo = fooPersistence.create(id); 
   Date now = new Date(); 
   foo.setCreateDate(now); foo.setCompanyId(companyId); 
   foo.setGroupId(groupId); 
   fooPersistence.update(foo);
   return foo; 

}
4

1 回答 1

2

有同样的问题。调试 ServiceBuilder 的代码后,我发现用于生成类的模板使用 service.xml 的 DTD 定义中的版本(检查 com.liferay.portal.tools.service.builder.jar 中的文件 persistence_impl.ftl)。确保那里有 7.3.0 而不是 7.2.0(甚至更早)。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.3.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_3_0.dtd">

<service-builder...>
于 2021-03-31T14:51:11.763 回答