jpa - Problems creating correct ddl from entities using eclipselink -
i have 2 entities person & status manytoone relation
@entity @table(name = "person") public class person implements serializable { @id @generatedvalue(strategy = generationtype.identity) private integer id; @column(name = "first_name") private string firstname; @column(name = "last_name") private string lastname; @joincolumn(name = "status_id", referencedcolumnname = "id") @manytoone(cascade = cascadetype.all) private status status; // setters & getters }
and
@entity @table(name = "status") public class status implements serializable { @id @generatedvalue(strategy = generationtype.identity) @column(name = "id") private integer id; @column(name = "abbreviation") private string abbreviation; @column(name = "title") private string title; @basic(fetch=fetchtype.lazy) @onetomany(mappedby = "status") private collection<person> personcollection; // setters & getters }
when try automatically generate db tables these entities following ddl:
create table `person` ( `id` int(11) not null auto_increment, `first_name` varchar(255) null default null, `last_name` varchar(255) null default null, `nick_name` varchar(255) null default null, `status_id` int(11) null default null, primary key (`id`), index `fk_person_status_id` (`status_id`), constraint `fk_person_status_id` foreign key (`status_id`) references `status` (`id`) ) create table `status` ( `id` int(11) not null auto_increment, `abbreviation` varchar(255) null default null, `personcollection` longblob null, `title` varchar(255) null default null, primary key (`id`)
)
obviously wrong because not need have personcollection longblob
field in status
table. doing wrong mapping?
using: netbeans 8, eclipselink, jpa 2.1, mysql 5.6
try remove @basic annotation use "list" instead of "collection"
Comments
Post a Comment