简体   繁体   English

将 Spring 引导数据插入 Postgresql 分区表?

[英]Insert with Spring Boot Data into Postgresql partitioned tables?

How to Insert/Save with Spring Boot Data in Postgresql partitioned tables?如何在 Postgresql 分区表中使用 Spring 引导数据插入/保存?

in the postgresql database, there is a trigger that creates the partition if it does not exist and then inserts it into the database in the child table.在postgresql数据库中,有一个触发器,如果分区不存在则创建分区,然后将其插入到数据库的子表中。

/*
table division logic
*/
EXECUTE 'INSERT INTO tableA.'|| partition_name ||' SELECT ($1).* ' USING NEW;
RETURN NULL;

when trying to insert in the database, through the command "repository.save()" then returns the error: "org.hibernate.StaleStateException: Unexpected row count: 0; expected: 1;"尝试插入数据库时,通过命令“repository.save()”然后返回错误:“org.hibernate.StaleStateException: Unexpected row count: 0; expected: 1;”

Your application doesn't see the difference between a partitioned and non-partitioned table.您的应用程序看不到分区表和非分区表之间的区别。 That logic is handled by the database.该逻辑由数据库处理。

By the way, use English.顺便说一句,使用英语。 Or post you question at the Portuguese section.或在葡萄牙语部分发布您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM