79226916

Date: 2024-11-26 13:36:13
Score: 3
Natty:
Report link

The issue arises because @GeneratedValue cannot be used with composite keys defined using @IdClass. To resolve this, remove @GeneratedValue and manage the id field manually. For Oracle, implement a service to fetch the next sequence value using a native query (SELECT <sequence_name>.NEXTVAL FROM DUAL). Before persisting the entity, set the id field using this service. For MariaDB, the database will handle the auto-increment behavior automatically.

Reasons:
  • No code block (0.5):
  • User mentioned (1): @GeneratedValue
  • User mentioned (0): @IdClass
  • User mentioned (0): @GeneratedValue
  • Single line (0.5):
  • Low reputation (1):
Posted by: Steve Rogers