Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't create composite primary key with foreign key in PLAY 2.0
    primarykey
    data
    text
    <p>This is a situation I want to represent in my PLAY project:</p> <pre><code>table clients { client_id (pk), description } table items { client_id (fk, pk), item_id (pk) } </code></pre> <p>In the 'items' table I want to have a composite primary key that will consist of combined client_id and item_id. I have read JPA documentation as well as many posts on the topic but everything fails again and again. This is one of many versions I have tried - closest to the JPA documentation.</p> <pre><code>@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; } //public int hashCode() {... //public boolean equals(Object obj) {... } </code></pre> <p>The above code (as well as many other different setups) produce following error during play launch:</p> <blockquote> <p>java.lang.RuntimeException: Error reading annotations for models.ItemsPK at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:73) ~[ebean.jar:na] at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1100) ~[ebean.jar:na]</p> </blockquote> <p>I don't have a clue what might be wrong with my code. I'm starting to think that it is a PLAY bug. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload