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.