java - JPA - Resolving relationships (ManyToMany + ManyToOne) -


i've got problem defining relationships, i've got entities:

datawarehouse

i've tryed make relationships in code, this:

project-datostabla

    @manytomany(cascade = cascadetype.merge) @jointable(name = "datostabla", joincolumns = @joincolumn(name = "idproject", referencedcolumnname = "idproject"), inversejoincolumns = @joincolumn(name = "idtable", referencedcolumnname = "idtable")) public set<datostabla> getdatostabla() {     return datostabla; } 

datostabla-project

    @manytomany(mappedby = "datostabla") public set<project> getproject() {     return project; } 

datostabla-atributosdatostabla

    @onetomany(fetch = fetchtype.lazy, mappedby = "datostabla") public set<atributosdatostabla> getatributodatostabla() {     return atributodatostabla; } 

atributosdatostabla-datostabla

    @manytoone(cascade = cascadetype.merge, fetch = fetchtype.lazy) @joincolumns({ @joincolumn(name = "idtable", referencedcolumnname = "idtable"),         @joincolumn(name = "project", referencedcolumnname = "project") }) public datostabla getdatostabla() {     return datostabla; } 

when run application, got error:

caused by: org.hibernate.mappingexception: foreign key (fk40oq9lkjvyu5b4s0x9j69uop4:atributosdatostabla [idtable])) must have same number of columns referenced primary key (datostabla [idproject,idtable])

i've tryed make composite key in atributosdatostabla doing this: atributosdatostabla-datostabla

    @manytoone(cascade = cascadetype.merge, fetch = fetchtype.lazy) @joincolumns({ @joincolumn(name = "idtable", referencedcolumnname = "idtable"),         @joincolumn(name = "project", referencedcolumnname = "project") }) public datostabla getdatostabla() {     return datostabla; } 

and got error: caused by: org.hibernate.mappingexception: unable find column logical name: project in datostabla

so, i'm quite stuck @ moment. knows way solve problem?


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -