-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Jsr310Converters
does not contain converters for OffsetTime
and OffsetDateTime
#2677
Comments
I moved this ticket into Spring Data Redis as it is a module-specific concern. We have already quite a few converters for JSR-310 types, however we don't have ones for One more aspect here: Since you're a bit familiar with our code, do you want to submit a pull request so that we can ship a fix with the next release? |
null
.Jsr310Converters
does not contain converters for OffsetTime
and OffsetDateTime
FTR: I was able to produce a similar problem (I suppose) by simply adding a Modified class Person {
private OffsetDateTime lastAccessed;
// other persistent properties
Person lastAccessed(OffsetDateTime lastAccessed) {
this.lastAccessed = lastAccessed;
return this;
}
} Modified class PersonRepositoryTests {
private Person arya = new Person("arya", "stark", Gender.FEMALE).lastAccessed(OffsetDateTime.now());
// ...
} Then I simply ran and debugged the I don't necessarily agree that we need "custom" SD Of course, it would need to be given a chance to serialize and persist The execution path for a persistent property of type
There should NOT need to be a "custom" Conversion since the I have only started investigating this issue so I am still scratching the surface. |
On closer inspection, this may be a simple fix, by simply registering additional Although, since Java's I doubt they were simply "forgotten". |
We never provided Zoned or Offset variants of temporal types on a broader basis because in typical stores working with dates, such a field requires two components (time, offset/zone) to be properly constructed without resorting to the system timezone. In Redis, since everything is a byte array, we weren't asked to provide converters and so they never got added in the first place. |
Hi, I'm facing the same problem of serialisation of an OffsetDateTime. Is there any workaround using configuration with RedisCustomConversions or RedisTemplate ? Like many i tried to implement my proper RedisTemplate with its custom serializer (ObjectMapper with JavaTimeModule from jackson-datatype-jsr310 or my custom one) but never consumed on sending. Here an example of the configuration i've done : Configuration:
Serializer:
Converter:
Object to send:
Publisher:
|
Yeah, I would like to have these as well.
Am 16. Aug. 2023, 19:32 +0200 schrieb John Blum ***@***.***>:
… @mp911de - Then, I guess 1 question I have is, why are we de/serializing ZonedDateTime, here?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
…va.time.OffsetDateTime and java.time.OffsetTime types. See spring-projects/spring-data-redis#2677.
I explored more on this issue today, and while Spring Data Redis currently does not support either I have demonstrated this in my redis-experiments project, within the spring-data-redis-experiments module, and specifically the RedisRepositoryWithEntityHavingOffsetDateTimePropertyIntegrationTests class. You can see that my Additionally, I have "customized" the SD (Redis) Repository infrastructure configuration, and specifically the " This allows you to add additional First, I defined custom Then, I simply replace the Alternatively, you could simply use the |
We now appropriately handle OffsetDateTime and OffsetTime the same as all other java.time types, supported as simple types on Spring application (persistent) entity classes. Closes spring-projects#2677
We now appropriately handle OffsetDateTime and OffsetTime the same as all other java.time types, supported as simple types on Spring application (persistent) entity classes. Closes spring-projects#2677
See #2681. |
We now appropriately handle OffsetDateTime and OffsetTime the same as all other java.time types, supported as simple types on Spring application (persistent) entity classes. Closes #2677
We now appropriately handle OffsetDateTime and OffsetTime the same as all other java.time types, supported as simple types on Spring application (persistent) entity classes. Closes #2677
Thank you very much 😄 Any idea when this would be in a release? |
Check out the release calendar at https://calendar.spring.io/. As of now, the next round of releases is scheduled for tomorrow. |
@jxblum Thank you very much for your response and investigation. I didn't succeed to use OffsetDateTime with redis streams (no repositories in my case) but just using ZonedDateTime type will do the trick for the moment :) |
When using
spring-data-redis
andRedisSerializer.java()
I noticed that a field of typeOffsetTime
wasn't being serialised even though it implementsSerializable
. The root cause is thatSimpleTypeHolder
assumes that any class that starts withjava.time
is a simple type (which in turn meansCustomConversions.isSimpleType(OffsetTime.class) == true
). This breaks the assumption thatCustomConversions
has a converter for the type as per the javadoc:Expected behaviour:
customConversions.isSimpleType
returns false if there are no converters forOffsetDateTime
orOffsetTime
Actual behaviour:
customConversions.isSimpleType(OffsetDateTime.class) == true
even if there are no converters forOffsetDateTime
(and forOffsetTime
Relevant Code links:
https://github.com/spring-projects/spring-data-commons/blob/541f0ced32f3f8b2143ea5b793a489828567ff13/src/main/java/org/springframework/data/mapping/model/SimpleTypeHolder.java#L158
https://github.com/spring-projects/spring-data-commons/blob/541f0ced32f3f8b2143ea5b793a489828567ff13/src/main/java/org/springframework/data/convert/CustomConversions.java#L190
The text was updated successfully, but these errors were encountered: