diff --git a/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java index e4da3b7dd..a875043a7 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java @@ -9,6 +9,7 @@ @RepositoryRestResource(collectionResourceRel = "gender", path = "gender") public interface GenderRepository extends CHSRepository, CustomCHSJpaRepository, FindByLastModifiedDateTime { Gender findByName(String name); + Gender findByNameAndOrganisationId(String name, Long organisationId); Gender findByNameIgnoreCase(String name); @RestResource(exported = false) diff --git a/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java b/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java index 9b45163d0..538ffc34e 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java @@ -915,7 +915,7 @@ public void addGroupDashboardJson(ZipOutputStream zos) throws IOException { } private void createGender(String genderName, Organisation org) { - if (Objects.nonNull(genderRepository.findByName(genderName))) { + if (Objects.nonNull(genderRepository.findByNameAndOrganisationId(genderName, org.getId()))) { return; } Gender gender = new Gender();