|
27 | 27 | import org.springframework.data.elasticsearch.repository.query.ElasticsearchStringQuery;
|
28 | 28 | import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
29 | 29 | import org.springframework.data.repository.core.NamedQueries;
|
| 30 | +import org.springframework.data.repository.core.RepositoryInformation; |
30 | 31 | import org.springframework.data.repository.core.RepositoryMetadata;
|
31 | 32 | import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
32 | 33 | import org.springframework.data.repository.query.QueryLookupStrategy;
|
@@ -59,36 +60,24 @@ public <T, ID extends Serializable> ElasticsearchEntityInformation<T, ID> getEnt
|
59 | 60 |
|
60 | 61 | @Override
|
61 | 62 | @SuppressWarnings({"rawtypes", "unchecked"})
|
62 |
| - protected Object getTargetRepository(RepositoryMetadata metadata) { |
63 |
| - |
64 |
| - ElasticsearchEntityInformation<?, ?> entityInformation = getEntityInformation(metadata.getDomainType()); |
65 |
| - |
66 |
| - AbstractElasticsearchRepository repository; |
67 |
| - |
68 |
| - // Probably a better way to store and look these up. |
69 |
| - if (Integer.class.isAssignableFrom(entityInformation.getIdType()) |
70 |
| - || Long.class.isAssignableFrom(entityInformation.getIdType()) |
71 |
| - || Double.class.isAssignableFrom(entityInformation.getIdType())) { |
72 |
| - // logger.debug("Using NumberKeyedRepository for " + metadata.getRepositoryInterface()); |
73 |
| - repository = new NumberKeyedRepository(getEntityInformation(metadata.getDomainType()), elasticsearchOperations); |
74 |
| - } else if (entityInformation.getIdType() == String.class) { |
75 |
| - // logger.debug("Using SimpleElasticsearchRepository for " + metadata.getRepositoryInterface()); |
76 |
| - repository = new SimpleElasticsearchRepository(getEntityInformation(metadata.getDomainType()), |
77 |
| - elasticsearchOperations); |
78 |
| - } else { |
79 |
| - throw new IllegalArgumentException("Unsuppored ID type " + entityInformation.getIdType()); |
80 |
| - } |
81 |
| - repository.setEntityClass(metadata.getDomainType()); |
82 |
| - |
83 |
| - return repository; |
| 63 | + protected Object getTargetRepository(RepositoryInformation metadata) { |
| 64 | + return getTargetRepositoryViaReflection(metadata,getEntityInformation(metadata.getDomainType()), elasticsearchOperations); |
84 | 65 | }
|
85 | 66 |
|
86 | 67 | @Override
|
87 | 68 | protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
|
88 | 69 | if (isQueryDslRepository(metadata.getRepositoryInterface())) {
|
89 | 70 | throw new IllegalArgumentException("QueryDsl Support has not been implemented yet.");
|
90 | 71 | }
|
91 |
| - return SimpleElasticsearchRepository.class; |
| 72 | + if (Integer.class.isAssignableFrom(metadata.getIdType()) |
| 73 | + || Long.class.isAssignableFrom(metadata.getIdType()) |
| 74 | + || Double.class.isAssignableFrom(metadata.getIdType())) { |
| 75 | + return NumberKeyedRepository.class; |
| 76 | + } else if (metadata.getIdType() == String.class) { |
| 77 | + return SimpleElasticsearchRepository.class; |
| 78 | + } else { |
| 79 | + throw new IllegalArgumentException("Unsuppored ID type " + metadata.getIdType()); |
| 80 | + } |
92 | 81 | }
|
93 | 82 |
|
94 | 83 | private static boolean isQueryDslRepository(Class<?> repositoryInterface) {
|
|
0 commit comments