对不起我的英语不好
我在 EclipseLink JPA 中映射实体有一些问题。我有一些实体:
@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;
...
}
在服务器端,这个实体映射到 Hibernate JPA 并且工作出色。但是在客户端我需要在 EclipseLink JPA 中映射这个实体(我使用 Eclipse RCP 4.x 和 Gemini DI),我有这个例外:
异常 [EclipseLink-46] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):org.eclipse.persistence.exceptions.DescriptorException 异常描述:应该为主键字段定义一个非只读映射 [TSENSOR .PSYSTEM]。描述符:RelationalDescriptor(watchdog.core.client.model.Sensor --> [DatabaseTable(TSENSOR)])
此问题仅与包含 EmbeddedId 的实体有关