79560893

Date: 2025-04-07 22:39:09
Score: 0.5
Natty:
Report link

Add a @DiscriminatorColumn to your Person entity to explicitly specify the column that differentiates the subtypes (Hunter, Policeman). This improves readability.

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "person_type")
public class Person { 
   // ...
}

How often do you need to access the dog associated with a Policeman? If it's very frequent, the performance benefit of your current approach becomes more significant.

If you anticipate a massive number of Hunters compared to Policemen, the wasted space due to NULLs in the dog_id column might become more of a concern. However, with modern databases, this is usually not a major issue unless you're dealing with truly enormous datasets.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: jsx97