When encountering this error, we mainly consider two aspects: one is the user’s permission, and the other is whether the table in the program corresponds to the table in the database, especially whether the table name is written correctly
I use the Oracle database connected by hibernate framework in the persistence layer
I asked the DBA to confirm that my current user does have read-write permission, especially for the table I reported an error; It shows that for other tables, there is no problem with insert, except for pri_ids_The mapping table is a dead or alive insert
The reason was later found:
@Entity @Table(name = "Pri_Ids_mapping") public class Pri_Ids_mapping { @Id @Column(name = "mapId", nullable = false) @SequenceGenerator(name = "seq_mapId", sequenceName = "SEQ_mapId",allocationSize= 1) @GeneratedValue(generator = "seq_mapId", strategy = GenerationType.SEQUENCE) private Long mapId; }
There was a problem during the generation of the primary key of this table. Because the name of my sequence is not associated with the table name, it is particularly easy to be replaced by the sequence of other tables
In fact, there is a table sequence and seq in another library_Duplicate mapid name. Allow my users to use synonyms of this sequence when creating tables; In addition, when creating a sequence, users of the library in which it is located are allowed to use this synonym. In this way, later sequences will overwrite the original ones; Now I want to generate ID with sequence, which involves cross database, so there is a problem of insufficient access rights
Solution:
@Entity @Table(name = "Pri_Ids_mapping") public class Pri_Ids_mapping { @Id @Column(name = "mapId", nullable = false) @SequenceGenerator(name = "seq_mapId", sequenceName = "fhl_pms.SEQ_mapId",allocationSize= 1) @GeneratedValue(generator = "seq_mapId", strategy = GenerationType.SEQUENCE) private Long mapId; }
When using sequences, just add the library name in front of them
Similar Posts:
- [Solved] EF An error occurred while updating the entries. See the inner exception for details.
- Postgres invalid command data recovery processing
- SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”
- The database returned no natively generated identity value [How to Solve]
- Kingbasees supports column encryption
- Thinkphp6 Error: constraint violation: 1052 Column ‘id’ in where clause is ambiguous
- MySQL database insert into statement with parameters Error
- SQL Error: 1064, SQLState: 42000 [Three Methods to Solve]
- [Solved] Oracle :value too large for column “SCHEMA”.”TABLE”.”COLUMN” (actual: 519, maximum: 500)
- MySQL Reading table information for completion of table and column names