Issue With @OneToMany and Abstraction in JPA -


i have issue one-to-many relationship. have abstract class artifact.java. not mapped table. there other concrete classes extending this, , mapped different tables. have class, mapped table, , class can have collection of of these classes, i.e. collection of type artifact.java. need map using jpa, , have done follows.

@onetomany(mappedby="artifactid",targetentity=artifact_item.class,         fetch=fetchtype.eager, cascade=cascadetype.all) private list<artifact_item> artifactitemlist; 

this results in following exception.

org.hibernate.annotationexception: use of @onetomany or @manytomany targeting unmapped class: dao.model.artifact.artifactitemlist[dao.model.artifact_item] 

can please me solve issue?

thanks.

alright, rephrasing question. have class, artifact.java, mapped table artifact. each artifact can have multiple sub items (one-to-many), aren't related in anyway. so, decided have abstract class artifactitem.java, sub items can extend this. thus, artifact has list of artifactitems.

artifactitem.java, , not mapped table. contains 2 elements, id , and artifactid, used foreign key. id has been marked @generatedvalue(strategy = generationtype.auto) , artifactid @manytoone(targetentity = artifact.class) @joincolumn(name = "artifact_id", referencedcolumnname = "id"). , class has been annotated @mappedsuperclass.

there numerous sub-items, extending artifactitem. each has own table, eg, artifacttype1.java has own fields , mapped artifacttype1 table , on.

now, since artifact.java's list needs mapped artifactitem, list collection of artifactitems. when try map in manner mentioned above, getting exception given above.

hope clearer :).

thanks.

use @mappedsuperclass on artifactitem (get rid of underscore)


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -