EDIT: How to save only the necessary columns in SELECT for Spring Data Conservation Projection?
Spring Data plays are good for getting a subset of columns for generated links, but in the query that is generated behind, all the columns in it.
How can you create projections where also SQL queries have only those columns in SELECT that are in Projection
, , spring ( spring) , - @Query. , :
public interface ActionId { String getId(); } @Query("select a.id as id from Action a where a.type = :type") public List<ActionId> findByType(@Param("type") String type);
, , . , , "Action" id, -
ref: https://github.com/spring-projects/spring-data-examples/blob/master/jpa/example/src/main/java/example/springdata/jpa/projections/CustomerRepository.java
, " ", .
: A bubi B, foo, bar, zed.
A
bubi
B
foo
bar
zed
B, :
@Projection(name="reduced", types = B.class) public interface BReduced { String foo; //exclude bar, for instance int zed; }
A.
@Projection(name="reduced", types = A.class) public interface AReduced { int bubi; BReduced b; }
SQL-?