Hello,
I have the following situation: I need to have a HashMap like this:
Code:
HashMap<ExtendedSeniorityType, SeniorityTotal>.
The contents of this HashMap do NOT need to be saved in the database, so this association is not mapped in the mapping file of the class that this HashMap is declared in.
ExtendedSeniorityType is an interface:
Code:
package data;
import enumerations.Profession;
public interface ExtendedSeniorityType {
public String getDescription();
public Profession getProfession();
}
There are 2 objects that implement this interface, but one of them in an enumeration:
Code:
package enumerations;
import data.ExtendedSeniorityType;
public enum SeniorityType implements ExtendedSeniorityType {
Administrative {
public String getDescription() {..}
public Profession getProfession() {...}
},
VE {
public String getDescription() {..}
public Profession getProfession() {...}
},
VO {
public String getDescription() {..}
public Profession getProfession() {...}
};
public abstract String getDescription();
public abstract Profession getProfession();
}
(I left out the code for getDescription() and getProfession())
The other is a normal class that can be persisted:
Code:
public class Subject extends AbstractGenericEntity<Long, Subject> implements ExtendedSeniorityType {
public String getDescription() {..}
public Profession getProfession() {...}
...
}
How can I map this structure in Hibernate? Normally, when using an interface, I would do it like described in
http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html
but it can't be done like that when one of the classes that implements the interface is an enumeration (because there's no way to declare a (sub)class that is an enumeration)...