I have something like that
table ACTION
name
resource_type
resource_id
resource_type and resource_id are used to discriminate type of resource:
resource_type can be image
or video
, if resource_type contains image
resource_id is id of the table IMAGE; if resource_type contains video
resource_id is id of the table VIDEO
here IMAGE and VIDEO tables
table IMAGE (*)
id
imageType
table VIDEO (*)
id
videoType
(*) tables are more complicated, but for better explanation I shrank it!!!
I have the following class, too
class Action{
private Resource resource;
//getter and setter
}
interface Resource{}
class Image implements Resource{
private Integer id;
private String imageType;
//getter and setter
}
class Video implements Resource{
private Integer id;
private String videoType;
//getter and setter
}
i tried to understand something about discriminator attribute from this tutorial: http://viralpatel.net/blogs/hibernate-inheritence-table-per-hierarchy-mapping/ but example is little bit diffenet...-_-'
I want map IMAGE end VIDEO table in Resource object of Action class,how I can map these pojo classes with hibernate xml mapper???