Interface CustomerRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Customer,,Long> org.springframework.data.jpa.repository.JpaRepository<Customer,,Long> org.springframework.data.repository.ListCrudRepository<Customer,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Customer,,Long> org.springframework.data.repository.PagingAndSortingRepository<Customer,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Customer>,org.springframework.data.repository.Repository<Customer,Long>
Customer entities.
Provides standard CRUD operations inherited from JpaRepository
and additional query methods specific to customer management.
The Customer entity extends
invalid reference
User
This repository is automatically implemented by Spring at runtime — no manual implementation required.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByMobile(String mobile) Deletes a customer by their mobile phone number.findByMobile(String mobile) Finds a customer by their mobile phone number.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByMobile
Finds a customer by their mobile phone number.Mobile number is often used as an alternative identifier for:
- Login via phone (SMS OTP)
- Account recovery / password reset
- Duplicate check during registration
- Admin/support lookup by phone
Assumes mobile numbers are stored in normalized format (e.g., digits only or with country code).
- Parameters:
mobile- the customer's mobile phone number (not null, not blank)- Returns:
- an
Optionalcontaining the matchingCustomerif found, orOptional.empty()if no customer has this mobile number
-
deleteByMobile
Deletes a customer by their mobile phone number.Convenience method that removes a customer without loading the entity first. Useful in scenarios such as:
- Account deletion request by phone identifier
- GDPR / right-to-be-forgotten compliance cleanup
- Admin tools performing bulk deletion by mobile
Warning: This is a destructive operation. Use with extreme caution and ensure proper authorization, logging, and soft-delete consideration.
- Parameters:
mobile- the mobile number of the customer to delete
-