In Hibernate, if I have an interface (not partially abstract class or concrete class)…
Jump to turn (15)
- 1In Hibernate, if I have an interface (not partially abstract class or concrete c
- 2Should Cat and Dog have some kind of annotation for stating that they inherit fr
- 3Is 2 correct even if Animal is an interface?
- 4So, in that case, would TABLEPERCLASS be the same as JOIN?
- 5Re-do your answer this time making sure to process that Animal is an interface a
- 6Should your most-recent answer include mention of @MappedSuperclass?
- 7Explain what @MappedSuperclass does in up to four sentences.
- 8So, in my case, I just need to do @Entity for Cat and Dog and do absolutely noth
- 9What does @Autowired do?
- 10In the post immediately above me asking about @Autowired, which strategy would b
- 11Provide code samples with and without @Autowired to emphasize how @Autowired hel
- 12What would one need to do beyond just typing @Annotation for it to work. Use a p
- 13When I most recently talked about strategy, I was referring to persistence strat
- 14How does one "enable component scanning and annotate the dependency and its inje
- 15When talking about strategies, I was not linking it to the @Autowired stuff; I w
- User
In Hibernate, if I have an interface (not partially abstract class or concrete class) Animal and concrete classes Cat and Dog, do I need to put @Entity for Animal too or just Cat and Dog?
- Assistant
In Hibernate, the @Entity annotation is used to mark a class as an entity that will be mapped to a database table.
If you want to persist objects of the Animal interface hierarchy in the database, you need to annotate the concrete classes Cat and Dog with the @Entity annotation.
However, since interfaces cannot be directly instantiated and mapped to database tables, there is no need to annotate the Animal interface with @Entity.
Only classes that can be instantiated and persisted directly should be annotated with @Entity.
- User