0

I have a class that has the following code:

@Entity
@Table(name="Node")
public class Node {
    @Id
    @Column(name="node_id")
    private Integer nodeId;
    @Enumerated(EnumType.STRING)
    private NodeType type;
    private EntityNode entityNode;

The entityNode object is actually an interface, that many other classes can implement, I just want to be able to map the entityNode to a column entity_id in the node table. Is this possible in JPA?

echew
  • 131
  • 1
  • 2
  • 11
  • Depending on what you're trying to accomplish, @Inheritance [https://stackoverflow.com/questions/2912988/persist-collection-of-interface-using-hibernate/2918468#2918468] annotation with a table-per-class strategy could be an option. – Keshavram Kuduwa Dec 31 '21 at 19:13
  • Thanks @KeshavramKuduwa, I wonder how the Inheritance annotation works in JPA, I will look into it. Otherwise using the abstract class seems reasonable as well. – echew Jan 04 '22 at 06:00

0 Answers0