[go: up one dir, main page]

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

Attribute converter like functionality for spring-cloud-gcp-data-datastore #438

Open
nbali opened this issue Apr 14, 2021 · 5 comments
Open

Comments

@nbali
Copy link
nbali commented Apr 14, 2021

Is your feature request related to a problem? Please describe.
I'm unable to do custom conversions of specific fields between the pojo and db state, because this widely available feature is missing from spring-cloud-gcp-data-datastore, 2.0.2

Describe the solution you'd like
https://www.baeldung.com/jpa-attribute-converters#using-the-converter for spring-cloud-gcp-data-datastore :)

Describe alternatives you've considered
Without spring data support, I'm forced to use https://github.com/objectify/objectify/blob/master/src/main/java/com/googlecode/objectify/annotation/Translate.java.

Additional context
The goal isn't to have a global converter that converts between type A and type B (I think that is already available), but to have an annotation that can control this at the field level OR a global converter that receives the Field object it's converting - so for example it can check for any kind of custom annotation being present. (For example creating a @Sensitive annotation that triggers an encryption during the conversion. https://aws.amazon.com/blogs/developer/client-side-encryption-for-amazon-dynamodb/ does something like this with @DoNotEncrypt).

@meltsufin meltsufin added datastore type: enhancement New feature or request labels Apr 14, 2021
@meltsufin
Copy link
Member

You're right about only global converters being currently supported as described here. If that doesn't work for you, something like JPA's @Convert would need to be added. Unfortunately, I don't think there is such a facility in Spring Data Commons (cc/ @mp911de).
As always, we welcome contributions.

@mp911de
Copy link
mp911de commented Apr 15, 2021

Right now, there's no infrastructure for property-specific converters. Neo4j and Elasticsearch went forward to introduce their store-specific mechanisms. We have a ticket in Spring Data Commons (spring-projects/spring-data-commons#1484) to design and come up with some infrastructure.

@nbali
Copy link
Author
nbali commented Apr 19, 2021

Well this tells me the "issue" is real, but just not painful enough for anybody, so everybody is doing a workaround instead. The issue was opened 4 years ago, and barely any interaction on it. Anyway I always thought it's strange it was missing from spring-data and this was usually the reason we went with JPA instead - when we could. My guess is JPA was a too easy and quick alternative for others as well. Not an option with datastore. Unfortunately my knowledge is far from deep enough to contribute code to such a huge feature - even so that I guess there is a reason Neo4j and Elasticsearch did the specific version as well, and not the general one.

So what is the expected flow here? Let the issue be dependent on that one, or should it be closed?

@mp911de
Copy link
mp911de commented Apr 19, 2021

We don't have a final design for the API and since we expect some changes in the actual store module I'd suggest keeping this ticket open.

@zhumin8
Copy link
Contributor
zhumin8 commented Aug 1, 2022

update: Spring Data Common has added "support for property-specific converters" in 3.0.0-M2

prash-mi pushed a commit that referenced this issue Jun 20, 2023
Bumps [reactor-bom](https://github.com/reactor/reactor) from 2020.0.10 to 2020.0.11.
- [Release notes](https://github.com/reactor/reactor/releases)
- [Commits](reactor/reactor@2020.0.10...2020.0.11)

---
updated-dependencies:
- dependency-name: io.projectreactor:reactor-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants