[JAVA][Liferay] Duplicate key value violates unique constraint for resourcepermissionid in Liferay

Unexpected exception thrown when create new site:

09:47:10,114 ERROR [ajp-bio-8009-exec-113][JDBCExceptionReporter:82] Batch entry 0 insert into ResourcePermission (companyId, name, scope, primKey, roleId, ownerId, actionIds, resourcePermissionId) values ('10157', 'com.liferay.portlet.documentlibrary.model.DLFileEntry', '4', '24728', '10173', '0', '3', '11366') was aborted.  Call getNextException to see the cause.
09:47:10,115 ERROR [ajp-bio-8009-exec-113][JDBCExceptionReporter:82] ERROR: duplicate key value violates unique constraint "resourcepermission_pkey"_  Detail: Key (resourcepermissionid)=(11366) already exists. [Sanitized]

Solution:

The doubling was caused by the Counter service (not sure what it actually does but assume it generates unique ids for primary keys).

These changes are in the tomcat\webapps\ROOT\WEB-INF\classes\portal-ext.properties file

##
## Counter
##

#
# The counter operates with is own data source to prevent deadlocks. By
# default, the data source created for the counter uses the same settings as
# those used to create the data source used for the rest of the portal. That
# happens by because the counter service will look up the properties
# prefixed with "jdbc.default." to create its data source. See the JDBC
# properties prefixed with "jdbc.default." for more information.
#
# Setting a different value for the counter JDBC prefix allows you to better
# fine tune the counter data source with its own set of configuration
# settings for high availability installations. Note that these settings,
# though separate, are a copy of the default settings with the newly
# overridden values.
#
counter.jdbc.prefix=jdbc.counter.
jdbc.counter.maxPoolSize=3
jdbc.counter.minPoolSize=1
jdbc.counter.numHelperThreads=1

#
# Set the number of increments between database updates to the Counter
# table. Set this value to a higher number for better performance.
#
counter.increment=100
时间: 2024-10-18 17:05:43

[JAVA][Liferay] Duplicate key value violates unique constraint for resourcepermissionid in Liferay的相关文章

Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "SAMS_SYS_AREA_pkey"

导致错误的原因: 我在建表的sql文件中,重新定义了一个自增表("id serial primark key"),但是sql文件中还有insert语句初始化数据,这是id自增字段就不是从1开始, 这时你在添加数据时就会出现标题中问题 解决办法: 在创建好表后,执行下面一句话 SELECT setval('"SAMS_SYS_AREA_id_seq"', (SELECT MAX(id) FROM "SAMS_SYS_AREA")+1)[设置] //

IntegrityError duplicate key value violates unique constraint - django/postgres

SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1)

JDK8 stream toMap() java.lang.IllegalStateException: Duplicate key异常解决(key重复)

测试又报bug啦 接到测试小伙伴的问题,说是一个接口不返回数据了,好吧,虽然不是我写的接口任务落到头上也得解决,本地调试了一下,好家伙,直接抛了个异常出来,这又是哪位大哥喝醉了写的代码... Exception in thread "main" java.lang.IllegalStateException: Duplicate key at java.util.stream.Collectors.lambda$throwingMerger$0(Collectors.java:133)

Caused by: java.lang.IllegalStateException: duplicate key: datasource

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yaml' at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:537) at org.springfram

分布式配置中心config-client配置报错:java.lang.IllegalStateException: duplicate key: spring

今天练习分布式配置中心,写config-client配置文件,使用bootstrap.properties配置,运行没有问题. bootstrap.properties: spring.application.name=config-client spring.cloud.config.label=master spring.cloud.config.profile=dev spring.cloud.config.uri= http://localhost:8888/ server.port=8

Oracle 唯一 约束(unique constraint) 与 索引(index) 关系说明

一. 官网对Unique Constraints说明 http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/datainte.htm#CNCPT1642 uniquekey constraint requires that every value in a column or set of columns beunique. No rows of a table may have duplicate values in a

Duplicate key name > ‘web_privilege_name_102618e8_

起源 在models中设置unique,多次migrate就会报下面的信息 raise errorclass, errorvalue django.db.utils.OperationalError: (1061, "Duplicate key name > 'web_privilege_name_102618e8_uniq'") 原因 Running migrations: (0.002) b'SHOW FULL TABLES'; args=None ALTER TABLE `

关于使用MySQL语法ON DUPLICATE KEY UPDATE单个增加更新及批量增加更新的sql

应用场景: 在实际应用中,经常碰到导入数据的功能,当导入的数据不存在时则进行添加,有修改时则进行更新, 在刚碰到的时候,第一反应是将其实现分为两块,分别是判断增加,判断更新,后来发现在mysql中有ON DUPLICATE KEY UPDATE一步就可以完成,感觉实在是太方便了, 该语句是基于唯一索引或主键使用,比如一个字段a被加上了unique index,并且表中已经存在了一条记录值为1. 比如: 下面两个语句会有相同的效果: INSERT INTO table (a,b,c) VALUES

on duplicate key update简单使用

1.最近在做项目的时候,遇到这样的一个问题,就是我每做完一件事情,都要更新一下统计表,然而要更新统计表,就要根据主键去统计表里面去查询是否已经有这样的一条记录,如果有那么就更新,如果没有那么就插入一条记录,开始我就是这么干的,结果被老大给否决了,他说可以用on duplicate key update去做.下面就实际操作一下吧: 表结构: +-----------+---------+------+-----+---------+-------+| Field     | Type    | N