I mapped some classes of an hierachy with strategy "TABLE PER CONCRETE CLASS", which also means my superclass
Element doens't have its own table. Subclasses of
Element are
ElementA and
ElementB, those have their own tables.
And then in an another entity, i mapped a ONE-TO-MANY Collection like this :
Code:
@OneToMany (fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name="i_fit_article")
private List<Element> elements = new ArrayList<>();
The problem is, i failed to either delete or adding elements into the List. When i tried to delete by using session.saveorUpdate(), it says
Quote:
java.lang.IllegalArgumentException: Removing a detached instance
And when i tried to add a new Element to the list :
Quote:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table Element doesnt exist.
Which is understandable, because there is no such table.
For clarity, my superclass is mapped like this.
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Element { ...
Getting elements from the database work completly okay though.
What did i do wrong here ? Thanks for any help.