Hello. I have some problem with entity mapping and I would be thankful if somebody help me.
There is an IMAGE table in database. Fields: id, name, path, source_id and source_type.
SOURCE_TYPE - can be property(image belongs to property), user(image belongs to user) and so on
source_id is something like foreign key(actually it isn't)...
For example if source_type is user,then source_id references to USER table.
If source_type is property, source_id references to PROPERTY table.
I have to map this Entity. So that for example PROPERTY entity had a Set<Image>, and USER entity had a Set<Image> and so on..
Those relations must be unidirectional..
@Entity
class Property {
//What annotations I should put here?
Set<Image> set..........
}
With Best regards, Maksim.
|