Answer the question
In order to leave comments, you need to log in
How to use One-to-Any, Many-to-Any polymorphic annotations in hibernate?
Help with an example of using the @Many-to-Any, @One-to-Any annotations. there is very little information on them on the Internet, and using such a simple solution is damn nice.
task.
HumanUnits
-id
-data
MachineUnits
-id
-anotherData
UnitTable
-id
-One-to-any (HumanUnit.id or MachineUnit.id) was
guided by examples from the internet ala
@Any(metaColumn = @Column(name = "ITEM_TYPE"))
@AnyMetaDef (idType = "long", metaType = "string",
metaValues = {
@MetaValue(targetEntity = Book.class, value = "B"),
@MetaValue(targetEntity = VHS.class, value = "V"),
@MetaValue(targetEntity = DVD.class, value = "D")
})
@JoinColumn(name="ITEM_ID")
private Object item;
with this type of annotation, the tables are quietly lined up. at insert'e I receive no errors, but tables remain empty.
java - 7, hibernate - 4.3.0, database type - postgresql 9.1.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question