0
我创建了一个播放应用程序,并有一些模型。其中一个包含一个对象设置,但JPA不能创建表...JPA @ElementCollection播放框架错误
package models;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Table;
import play.db.jpa.Model;
@Entity
public class Receipt extends Model {
@ElementCollection
Set<Serving> servings;
DiningTable table;
public Receipt(Set<Serving> servings, DiningTable table) {
super();
this.servings = servings;
this.table = table;
}
}
和错误是
21:20:47,323 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ... 21:20:51,935 INFO ~ Connected to jdbc:mysql://localhost/rms_?>useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci 21:20:52,827 ERROR ~ Unsuccessful: create table Receipt (id bigint not null auto_increment, >table tinyblob, primary key (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 21:20:52,827 ERROR ~ You have an error in your SQL syntax; check the manual that >corresponds to your MySQL server version for the right syntax to use near 'table tinyblob, >primary key (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8' at line 1 21:20:53,183 ERROR ~ Unsuccessful: alter table Receipt_Serving add index FKB18778C559F3AF16 >(Receipt_id), add constraint FKB18778C559F3AF16 foreign key (Receipt_id) references Receipt >(id) 21:20:53,183 ERROR ~ Can't create table 'rms_.#sql-731_f2' (errno: 150) 21:20:53,414 INFO ~ Application 'rms' is now started !
我怎样才能解决这个问题?
哪些关系注释?像manytoone或manytomany? – 2012-04-03 19:05:49
由于您没有收据上的表格集合,它将是\ @ManyToOne。你确定你想在你的服务中使用\ @ElementCollection吗?它是\ @Embedable,你不想单独查询?也许你应该考虑\ @OneToMany? – barsju 2012-04-03 19:16:00
http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection – barsju 2012-04-03 19:17:02