I have a table I cannot change with approximately this structure
ID, name, purpose, rubbish...
1, foo, PRICING, ...
2, bar, INVENTORY, ...
3, bar, PRICING, ...
What is the preferred way to map only the lines with purpose=PRICING to an Entity? Is there a way to do this with JPA annotations or do I need a view?
You might use SINGLE_TABLE inheritance strategy, and use "purpose" as discriminator column like this:
@Entity
@Table(name="THE_TABLE")
@Inheritance(strategy=SINGLE_TABLE)
@DiscriminatorColumn(name="purpose", discriminatorType=STRING)
@DiscriminatorValue("PRICING")
public class Pricing{ ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With