Reputation: 3
Sorry for my English
I have some problems with mapping entity in EclipseLink JPA. I have some entity:
@Entity
@Table(name = "TSENSOR")
@Cacheable
public class Sensor extends Model implements Serializable {
@EmbeddedId
SensorIdentifier key;
@Column(name = "CDESCRIPTION", columnDefinition = "TEXT")
String description;
@Column(name = "CTYPE")
@Enumerated(EnumType.STRING)
SensorType type;
...
}
@Embeddable
public class SensorIdentifier extends DeviceIdentifier {
@Column(name = "PNUM")
byte num;
...
}
@Embeddable
@MappedSuperclass
public class DeviceIdentifier extends Model implements Serializable {
@Column(name = "PSYSTEM", insertable = false, updatable = false)
String systemName;
@Column(name="PDEVICEID")
int id;
@Column(name="PDEVICESUBID")
short subId;
...
}
On server-side this entity mapped in Hibernate JPA and work excelent. But on client i need mapped this entity in EclipseLink JPA (I work with Eclipse RCP 4.x and Gemini DI), and i had this exception:
Exception [EclipseLink-46] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DescriptorException Exception Description: There should be one non-read-only mapping defined for the primary key field [TSENSOR.PSYSTEM]. Descriptor: RelationalDescriptor(watchdog.core.client.model.Sensor --> [DatabaseTable(TSENSOR)])
This problem only with entity contains EmbeddedId
Upvotes: 0
Views: 2369
Reputation: 2112
The error says that you should have one mapping for
@Column(name = "PSYSTEM", insertable = false, updatable = false)
String systemName;
that can be written to. (non-read-only) So one other mapping for PSYSTEM with insertable or updatable on true.
Upvotes: 4