BAEL 575: Pull request for Projections and Aggregation in Spring Data MongoDB (#1047)
* BAEL-575 - update spring data mongodb version to 1.9.6, update query dsl version to 4.1.4, Add constuctor to user class, add projection tests * BAEL-575 - Add aggregation test files and zips.json resource
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
af44518a6a
commit
6f9e6e0f20
@@ -13,7 +13,7 @@ import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
import com.mysema.query.annotations.QueryEntity;
|
||||
import com.querydsl.core.annotations.QueryEntity;
|
||||
|
||||
@QueryEntity
|
||||
@Document
|
||||
@@ -37,6 +37,11 @@ public class User {
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String name, Integer age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@PersistenceConstructor
|
||||
public User(final String name, @Value("#root.age ?: 0") final Integer age, final EmailAddress emailAddress) {
|
||||
|
||||
@@ -26,4 +26,10 @@ public interface UserRepository extends MongoRepository<User, String>, QueryDslP
|
||||
List<User> findByNameStartingWith(String regexp);
|
||||
|
||||
List<User> findByNameEndingWith(String regexp);
|
||||
|
||||
@Query(value="{}", fields="{name : 1}")
|
||||
List<User> findNameAndId();
|
||||
|
||||
@Query(value="{}", fields="{_id : 0}")
|
||||
List<User> findNameAndAgeExcludeId();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user