jpa - ManyToOne relation connect via embbeded fielld -


jpa/spring-data question

i have class plant has embbededid plantid , have class image embbeded field plantid

this means each image connect plant. connection 1 many (one plant many image)

i tried that(which doesnt work)

@entity public class plant{      @embbededid      plantid id }  @entity public class image{      @id      long id       @embbeded      plantid plantid       @manytoone      plant plant  } 

how can fix code result i'm looking for? thanks

oak

edit: how can map columns manytoone relation if have composite id plant?

all missing once remove plantid embeddable join column definitions on manytoone mapping jpa knows foreign keys use match id fields in plant. like:

@manytoone @joincolumns({         @joincolumn(name="fk_1", referencedcolumnname="pk1"),         @joincolumn(name="fk_2", referencedcolumnname="pk2"),         @joincolumn(name="fk_3", referencedcolumnname="pk3")          }) plant plant; 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -