@Target(value=TYPE) @Retention(value=RUNTIME) public @interface SelectQuery
@Entity
@SelectQuery(select ssn as id, concat(firstname, concat(lastname,',')) as full_name, dob as dob FROM myTable)
public class Person {
@Id
private Long id;
private String fullName;
private date dob;
}
Will generate view in Teiid as follows
CREATE VIEW person {
id long;
dob date,
full_name string,
PRIMARY KEY(id)
AS select ssn as id, dob as dob, concat(firstname, concat(lastname,',')) as full_name FROM myTable;
IMPOTANT: No matter how the ordering of your attributes in the
@Entity class, JPA(Hibernate) framework generates View columns in
ALPHABETICAL order. So, in @SelectQuery the ordering of the columns in
select clause MUST match to that of JPA generation. If you do not follow this
you will either end with validation errors, or with wrong data. In the above
example see how the 'dob' and 'fullName' attributes have been changed in
order.SpringPhysicalNamingStrategy
class. Which converts column names with under scores ("_"). You can define
your own naming strategy by defining the property as below example. The
example below will keep the names intact as defined.
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
For more information checkout DDL
support in Teiidpublic abstract String value
Copyright © 2019. All rights reserved.