I’m using play framework 1.2.4 and i’m preparing an meal order system. So i want to get them in a map.
package models;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import play.db.jpa.Model;
@Entity
public class Order extends Model{
Map<Item, Float> orders;
Table table;
Date date;
public Order(Map<Item, Float> orders, Table table) {
super();
this.orders = orders;
this.table = table;
date = new Date();
}
}
But when i start the application it gives this error,
JPA error
A JPA error occurred (Unable to build EntityManagerFactory): Could not determine type for: java.util.Map, at table: Order, for columns: [org.hibernate.mapping.Column(orders)]
How can i store orders like 1 porsion pizza, 1.5 porsion soup etc.
You must change table name for the entity Order by using @Table annotation. In many DBMS “order” is a reserved word.
About order items: you need other entity for storing this data. For example:
OrderItem.java