I am using spring-data-ldap to find all the users who are created or modified in a certain date range. My UserRepository
package com.test.service.ldap.com;
import org.springframework.data.ldap.repository.LdapRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UserRepository extends LdapRepository<User> {}
My User class
package com.test.service.ldap.com;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.domain.Persistable;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import org.springframework.ldap.odm.annotations.Transient;
import javax.naming.Name;
import java.util.Date;
@Entry(base = "ou=people,dc=example,dc=com",objectClasses = { "top","person","organizationalPerson","inetOrgPerson" })
@Data
@ToString
public final class User implements Persistable<Name> {
private @Id Name id;
private @Attribute(name = "cn") String firstname;
private @Attribute(name = "sn") String lastname;
private @Attribute(name = "mobile") String mobile;
private @Attribute(name = "createTimestamp") Date createdtime;
private @Attribute(name = "modifyTimestamp") Date modifiedtime;
@Transient
private Boolean isNew = false;
@Override
public boolean isNew() {
return isNew;
}
}
I get the below exception when I try to findAll()
org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value '20221229074251.850Z'
at org.springframework.core.convert.support.ObjectToObjectConverter.convert(ObjectToObjectConverter.java:117)
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:175)
at org.springframework.ldap.odm.typeconversion.impl.ConversionServiceConverterManager.convert(ConversionServiceConverterManager.java:67)
...
...
I want to know
- How to handle Date data type in spring-data-ldap
- Can I use something like findAllOrderByModifiedTimeDesc or use Between two dates