Package org.teiid.spring.annotations
Annotation Type SelectQuery
-
@Target(TYPE) @Retention(RUNTIME) public @interface SelectQuery
Defines the Teiid View's Transformation query. This is must have annotation to define Entity as View.
If you defined a @Entity annotation on a JAVA class and would like to use this class as View definition in Teiid, then use this annotation to define, how Teiid can build this View based on other Tables and Views.
For example for entity class:
@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; }
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;
NOTE: If you used CamelCase for your attributes in the Entity class, the generated Teiid's View class columns will be based on the Naming Strategy that is configured. By default SpringBoot usesSpringPhysicalNamingStrategy
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
-
-
Element Detail
-
value
String value
- Default:
- ""
-
-