Answer the question
In order to leave comments, you need to log in
How to inherit @Entity not mapped class in Hibernate?
The Field entity is required, which will be inherited by such classes as SliderField, DateField, etc., while they only perform the wrapper function and their data is already stored by Field in the form of an ArrayList
. It looks like this:
@Entity
class Field{
public String val1;
// ...
public ArrayList<Data> data;
//...
}
class SliderField extends Field{
public int min.max;
public void setMin(int m);
// ....
}
Answer the question
In order to leave comments, you need to log in
If I understand correctly, all classes are projected onto one table. At the same time, Field contains projections of those fields of the table that are used in all classes, and Field's heirs project additional fields specific to them. In this case, the following construction should be suitable:
@MappedSuperclass
abstract class Field {
//...
}
@Entity
@Table(name = "FIELDS")
class SliderField extends Field {
//...
}
@Entity
@Table(name = "FIELDS")
class DateField extends Field {
//...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question