• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA error while using composite primary key : help

 
ambika mullasseri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i have a table gradeid with primary key is gradeid
i have another table Leave_grade_mapping which has a composite primary key.(id1,id2,gradeif(FK of grade table))

when i run the code i get the following exception


[EL Info]: 2009-11-06 16:46:00.983--ServerSession(5195164)--EclipseLink, version: Eclipse Persistence Services - 1.1.2.v20090612-r4475
[EL Severe]: 2009-11-06 16:46:01.764--ServerSession(5195164)--Local Exception Stack:
Exception [EclipseLink-0] (Eclipse Persistence Services - 1.1.2.v20090612-r4475): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------

Exception [EclipseLink-48] (Eclipse Persistence Services - 1.1.2.v20090612-r4475): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field [leave_grade_mapping.GRADE]. Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[gradeBean]
Descriptor: RelationalDescriptor(com.myoffice.hr.dao.entities.Leave_grade_mapping --> [DatabaseTable(leave_grade_mapping)])


thank you
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you have a Basic (@Id) and a @OneToOne using the same column. You need to set insertable/updateable=false in one of them.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic