JPA Error compiling query when using Oracle objects within a query
The following JPA query doesn't compile -
SELECT a FROM CUSTOMER a WHERE a.activeCustomer = 'N' AND a.customerInfo.city IN :cityName ORDER BY a.customerId
where the t开发者_开发百科able CUSTOMER in Oracle database has a base type - CUSTOMERINFO which in turn has various values such as - city country
This base type CUSTOMERINFO is extended by LOCALBUSINESSCUSTOMERINFO and MNCBUSINESSCUSTOMERINFO and a few others.
I think this may be due to the fact that when I define the column in my entity I define it as follows -
@Entity
@Table(name = "CUSTOMER", schema = "DBA")
@Converter(name="CustomerInfoConvertor", converterClass=CustomerInfoConvertor.class)
public class Customer implements Serializable {
@Basic
@Convert("CustomerInfoConvertor")
@Column(columnDefinition = "CUSTOMERINFO")
private ICustomerInfo customerInfo;
}
I have tried this query using SQL and it works fine but using it from JPA (JPQL) throws compilation error.
Thanks for your help!
You have mapped your customerInfo as a basic, so it is a basic in JPQL.
The column is of an Object object type?
In EclipseLink 2.3 you can map this as an Embeddable and the @Struct annotation, and use an Embedded mapping from the Customer. Does the customer table have other columns or is it a type table? If it is a type table, then use the @Struct to map it.
精彩评论