java - Hibernate does not accept ManyToOne as Id -
hibernate not agree construction. missing anything? error throws me:
org.hibernate.mappingexception: unable find column logical name: version_id in processes
any suggestions on how fix while keeping composite key structure?
datamodel
version has many actions
version has many processes;
public class version { @id @column(name = "id") public int id; }
action has 1 process
action has 1 version
public class action { // action has composite key (id , version id) @id @column(name = "id") public int id; @id @manytoone @joincolumn(name = "version_id") public version version; @manytoone @joincolumns({ @joincolumn(name = "process_id", referencedcolumnname = "id"), @joincolumn(name = "version_id", referencedcolumnname = "version_id") }) public process process; }
process has many actions
process has 1 version
public class process { // process has composite key (id , version id) @id @column(name = "id") public int id; @id @manytoone @joincolumn(name = "version_id") public version version; @onetomany(fetch = fetchtype.lazy, mappedby = "process", targetentity = action.class) public list<action> actions= new arraylist<action>(); }
picture of model: https://dl.dropboxusercontent.com/u/2294873/model.jpg
you have 2 columns named version_id in action class. try renaming second version_id process_version_id:
public class action { // action has composite key (id , version id) @id @column(name = "id") public int id; @id @manytoone @joincolumn(name = "version_id") public version version; @manytoone @joincolumns({ @joincolumn(name = "process_id", referencedcolumnname = "id"), @joincolumn(name = "process_version_id", referencedcolumnname = "version_id") }) public process process; }
Comments
Post a Comment