Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Repository query projections [DATAGEODE-262] #310

Open
spring-projects-issues opened this issue Nov 4, 2019 · 0 comments
Assignees
Labels
in: api Issues with API in: repository Repositories abstraction type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

John Blum opened DATAGEODE-262 and commented

This improvement will track the development of Repository query method projections.

Typically, SD [Geode] Repositories are tied to a single application domain object type. However, query methods, whether by convention or annotated with @Query, can return a custom type containing a subset of the properties from the actual domain object itself (the "projection").

For example, I may have defined a Customer like so...

@Region("Contacts")
class Contact {

  Address address;

  Customer customer;

  PhoneNumber phoneNumber;

  String email;

...
}

Any one of the composed types (e.g. Customer) can be arbitrarily complex. Currently, the corresponding [CRUD] Repository might look like the following containing a query to find all Contacts in a particular city/state.

interface ContactRepository extends CrudRepository<Customer, Long> {

  List<Contact> findByAddressCityAndAddressState(State state, String city);
}

Depending on the application view, the user may only want a subset of the data returned from the query to project into the view. In other words, rather than returning the entire Contact, the user may want to only find all Customers by first and last name with phone number in a given city/state.

For example...

<code:java}
interface ContactRepository extends CrudRepository<Customer, Long> {

List<CustomerView> findByAddressCityAndAddressState(State state, String city);
}


With the corresponding, given `CustomerView`...

```java 
class CustomerView {

  PhoneNumber phoneNumber;

  String accountNumber;
  String firstName;
  String lastName;
}

Repository query projection support effectively allows the user to redefine their query method with the data of interests.


Reference URL: https://jira.spring.io/browse/SGF-523

@spring-projects-issues spring-projects-issues added in: repository Repositories abstraction type: enhancement A general enhancement in: api Issues with API labels Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: api Issues with API in: repository Repositories abstraction type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants