4 java google-app-engine entity-relationship jdo java-ee
我们很难在Google App Engine项目中保留数据,我们有"客户","预订"和"房间"等课程.
我们的目标是映射这些关系,从客户到预订的一对多关系以及从房间到同一预订的一对多关系.
我们得到的例外是:
no.hib.mod250.asm2.model.Reservation.id的元数据错误:不能有java.lang.Long主键并且是子对象(拥有字段是no.hib.mod250.asm2.model.Customer .RES).
我们的代码如下:
Customer.java
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Customer implements Serializable {
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
private Long id;
(...)
//an customer has one or more reservations.
@Persistent(mappedBy="customer")
private List <Reservation> res;
(...)
}
Run Code Online (Sandbox Code Playgroud)
Room.java
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Room implements Serializable {
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
private Long id;
(...)
//a room has one or more reservations
@Persistent(mappedBy="room")
private List<Reservation> res;
@Persistent
private Hotel hotel;
(...)
}
Run Code Online (Sandbox Code Playgroud)
Reservation.java
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Reservation implements Serializable {
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
private Long id;
(...)
@Persistent
private Room room;
@Persistent
private Customer customer;
(...)
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4776 次 |
最近记录: |