use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class QueryMapperUnitTests method shouldMapCountFunction.
// DATAJDBC-318
@Test
public void shouldMapCountFunction() {
Table table = Table.create("my_table").as("my_aliased_table");
Expression mappedObject = mapper.getMappedObject(Functions.count(table.column("alternative")), context.getRequiredPersistentEntity(Person.class));
assertThat(mappedObject).hasToString("COUNT(my_aliased_table.\"another_name\")");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class QueryMapperUnitTests method shouldMapExpression.
// DATAJDBC-318
@Test
public void shouldMapExpression() {
Table table = Table.create("my_table").as("my_aliased_table");
Expression mappedObject = mapper.getMappedObject(table.column("alternative").as("my_aliased_col"), context.getRequiredPersistentEntity(Person.class));
assertThat(mappedObject).hasToString("my_aliased_table.\"another_name\" AS my_aliased_col");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class QueryMapperUnitTests method shouldMapExpressionWithoutEntity.
// DATAJDBC-318
@Test
public void shouldMapExpressionWithoutEntity() {
Table table = Table.create("my_table").as("my_aliased_table");
Expression mappedObject = mapper.getMappedObject(table.column("my_col").as("my_aliased_col"), null);
assertThat(mappedObject).hasToString("my_aliased_table.my_col AS my_aliased_col");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class QueryMapperUnitTests method shouldMapExpressionToUnknownColumn.
// DATAJDBC-318
@Test
public void shouldMapExpressionToUnknownColumn() {
Table table = Table.create("my_table").as("my_aliased_table");
Expression mappedObject = mapper.getMappedObject(table.column("unknown").as("my_aliased_col"), context.getRequiredPersistentEntity(Person.class));
assertThat(mappedObject).hasToString("my_aliased_table.unknown AS my_aliased_col");
}
use of org.springframework.data.relational.core.sql.Table in project spring-data-jdbc by spring-projects.
the class SqlContext method getTable.
Table getTable(PersistentPropertyPathExtension path) {
SqlIdentifier tableAlias = path.getTableAlias();
Table table = Table.create(path.getTableName());
return tableAlias == null ? table : table.as(tableAlias);
}
Aggregations