I have JPA entities in an inheritance relationship of the type InheritanceType.JOINED. The top-level class is an abstract Payment class, which has several concrete subclasses. Meanwhile, the Order class has an association with Payment.
The Order class is indexed since I want to search for orders on various fields the Order class has, but I also want to search for orders on the single Payment attribute that all payments have.
Here is some code:
Order.java
Code:
@Entity
@Table(name = "WIDGET_ORDER")
@Indexed
public class Order {
.
.
.
@OneToOne(fetch= FetchType.LAZY, cascade= CascadeType.PERSIST)
@JoinColumn(name = "PAYMENT_ID", nullable = true)
public Payment getPayment() {
return payment;
}
.
.
.
}
Payment.java
Code:
@Entity
@Table(name = "PAYMENT")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Payment {
.
.
.
@Column(name = "COMMON_PAYMENT_ATTRIBUTE", nullable = true)
public String getCommonPaymentAttribute() {
return commonPaymentAttribute;
}
.
.
.
}
I am curious about how I can search for orders based on payments. Do I apply @Indexed at the Payment level or at the subclass level? And where do I apply @Field and @Boost? At the Payment level? Or do I override the getCommonPaymentAttribute method at the subclass level and apply the annotations to each method?
Any insight here is appreciated.
Thanks.