This is the situation I want to introduce in the PLAY project:
table clients { client_id (pk), description } table items { client_id (fk, pk), item_id (pk) }
In the "items" table, I want to have a composite primary key that will consist of a combined client_id and item_id. I read the JPA documentation, as well as a lot of posts on this topic, but everything happens again and again. This is one of the many versions I've tried - closest to the JPA documentation.
@Entity @Table(name = "items") public class Items extends Model { ItemsPK primaryKey; public Items() { } @EmbeddedId public ItemsPK getPrimaryKey() { return primaryKey; } public void setPrimaryKey(ItemsPK pk) { primaryKey = pk; } } @Embeddable public class ItemsPK implements Serializable { private long itemId; private Client client; public ItemsPK() { } @Column(name = "item_id") @GeneratedValue(strategy = GenerationType.AUTO) public long getItemId() { return itemId; } public void setItemId(long itemId) { this.itemId = itemId; } @ManyToOne @JoinColumn(name = "client_id", nullable = false) public Client getClient() { return client; } public void setClient(Client client) { this.client = client; }
In the above code (as well as in many other settings), the following error occurs during launch launch:
java.lang.RuntimeException: error reading annotations for models.ItemsPK at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations (ReadAnnotations.java:73) ~ [Ebean.jar: on] at com.avaje.ebeaninternal .server.deploy.BeanDescriptorManager.readDeployAssociations (BeanDescriptorManager.java:1100) ~ [Ebean.jar: on]
I have no clue what might be wrong with my code. I'm starting to think this is a PLAY error. Any ideas?
source share