Support enum arguments on repository queries.
Support enum in AbstractCouchbaseConverter.convertForWriteIfNeeded() and also call that from MappingCouchbaseConverter.getPotentiallyConvertedSimpleWrite() Closes #1069. Original pull request: #1112. Co-authored-by: mikereiche <michael.reiche@couchbase.com>
This commit is contained in:
committed by
mikereiche
parent
fe8d3feb48
commit
d16bbff4fe
@@ -50,6 +50,9 @@ public interface AirportRepository extends PagingAndSortingRepository<Airport, S
|
||||
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
|
||||
Airport findByIata(String iata);
|
||||
|
||||
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
|
||||
Airport findByIata(Iata iata);
|
||||
|
||||
@Query("#{#n1ql.selectEntity} where iata = $1")
|
||||
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
|
||||
List<Airport> getAllByIata(String iata);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
public enum Iata {
|
||||
vie,
|
||||
xxx
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import org.springframework.data.couchbase.core.query.QueryCriteria;
|
||||
import org.springframework.data.couchbase.domain.Address;
|
||||
import org.springframework.data.couchbase.domain.Airport;
|
||||
import org.springframework.data.couchbase.domain.AirportRepository;
|
||||
import org.springframework.data.couchbase.domain.Iata;
|
||||
import org.springframework.data.couchbase.domain.Person;
|
||||
import org.springframework.data.couchbase.domain.PersonRepository;
|
||||
import org.springframework.data.couchbase.domain.User;
|
||||
@@ -167,6 +168,18 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByEnum() {
|
||||
Airport vie = null;
|
||||
try {
|
||||
vie = new Airport("airports::vie", "vie", "loww");
|
||||
vie = airportRepository.save(vie);
|
||||
Airport airport2 = airportRepository.findByIata(Iata.vie);
|
||||
assertEquals(airport2.getId(), vie.getId());
|
||||
} finally {
|
||||
airportRepository.delete(vie);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testCas() {
|
||||
User user = new User("1", "Dave", "Wilson");
|
||||
|
||||
Reference in New Issue
Block a user