Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
IGNITE-16124 change signature in method deleteAllById in spring data …
…2.2 (#94) * IGNITE-16124 change signature in method deleteAllById in spring data 2.2
- Loading branch information
1 parent
f664082
commit 84bda12f11da9215883ee6da9c937222d8cab8ba
Showing
6 changed files
with
182 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -104,6 +104,6 @@ | ||
* | ||
* @param ids List of ids to delete. | ||
*/ | ||
public void deleteAllById(Iterable<K> ids); | ||
public void deleteAllById(Iterable<? extends K> ids); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,80 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.ignite.springdata; | ||
|
||
import org.apache.ignite.springdata.compoundkey.City; | ||
import org.apache.ignite.springdata.compoundkey.CityKeyExt; | ||
import org.junit.Test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
/** | ||
* Test with using ext compound key in spring-data. | ||
*/ | ||
public class IgniteSpringDataCompoundExtendedKeyTest extends IgniteSpringDataCompoundKeyTest { | ||
|
||
/** | ||
* Cities count. | ||
*/ | ||
private static final int TOTAL_COUNT = 6; | ||
|
||
/** | ||
* Test city Harare. | ||
*/ | ||
private static final City HARARE = new City("Harare", "Harare", 3120917); | ||
|
||
/** | ||
* Load data. | ||
*/ | ||
public void loadData() { | ||
repo.save(new CityKeyExt(1, "AFG", 11), new City("Kabul", "Kabol", 1780000)); | ||
repo.save(new CityKeyExt(2, "AFG", 12), new City("Qandahar", "Qandahar", 237500)); | ||
repo.save(new CityKeyExt(3, "AFG", 13), new City("Herat", "Herat", 186800)); | ||
repo.save(new CityKeyExt(4, "AFG", 14), new City("Mazar-e-Sharif", "Balkh", 127800)); | ||
repo.save(new CityKeyExt(5, "NLD", 25), new City("Amsterdam", "Noord-Holland", 731200)); | ||
repo.save(new CityKeyExt(6, "ZW", 36), new City("Harare", "Harare", 3120917)); | ||
} | ||
|
||
/** Test. */ | ||
@Test | ||
public void test() { | ||
assertEquals(Optional.of(KABUL), repo.findById(new CityKeyExt(1, "AFG", 11))); | ||
assertEquals(Optional.of(HARARE), repo.findById(new CityKeyExt(6, "ZW", 36))); | ||
} | ||
|
||
/** Test. */ | ||
@Test | ||
public void deleteAllById() { | ||
Set<CityKeyExt> keys = new HashSet<>(); | ||
keys.add(new CityKeyExt(1, "AFG", 11)); | ||
keys.add(new CityKeyExt(2, "AFG", 12)); | ||
keys.add(new CityKeyExt(3, "AFG", 13)); | ||
keys.add(new CityKeyExt(4, "AFG", 14)); | ||
keys.add(new CityKeyExt(5, "NLD", 25)); | ||
keys.add(new CityKeyExt(6, "ZW", 36)); | ||
|
||
repo.deleteAllById(keys); | ||
assertEquals(0, repo.count()); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override protected int getTotalCount() { | ||
return TOTAL_COUNT; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.springdata.compoundkey; | ||
|
||
import java.util.Objects; | ||
|
||
/** Extended city compound key. */ | ||
public class CityKeyExt extends CityKey { | ||
|
||
/** City extended identifier. */ | ||
private long idExt; | ||
|
||
/** | ||
* @param id city identifier | ||
* @param countryCode city countrycode | ||
* @param idExt city extended identifier | ||
* */ | ||
public CityKeyExt(int id, String countryCode, long idExt) { | ||
super(id, countryCode); | ||
this.idExt = idExt; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
|
||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
|
||
if (!super.equals(o)) | ||
return false; | ||
|
||
CityKeyExt that = (CityKeyExt) o; | ||
|
||
return idExt == that.idExt; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public int hashCode() { | ||
return Objects.hash(super.hashCode(), idExt); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public String toString() { | ||
return idExt + "|" + super.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters