Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

327
Views
¿Cómo manejar los objetos devueltos por findBy... Existe (existe booleano) en Spring-Data-MongoDB?

Tengo una colección en MongoDB llamada 'clientes' donde almaceno documentos con diferentes esquemas.

En mi aplicación Spring Boot tengo el siguiente repositorio:

 public interface BgradeCustomerRepository extends MongoRepository<BgradeCustomer, String> { public List<BgradeCustomer> findByScoreExists(boolean exists); }

Cuando invoco findByScoreExists y paso true, funciona bien y obtengo la colección de objetos con la propiedad 'score', pero el problema es que cuando paso false a findByScoreExists, obtengo la colección de objetos 'BgradeCustomer' con solo las propiedades comunes con los otros esquemas!!

Cambié la firma del método para que sea:

 // Customer is the other schema in the collection public List<Customer> findByScoreExists(boolean exists);

pero eso nunca funcionó, siempre obtengo 'java.lang.NullPointerException: null'

Entonces, ¿cómo puedo obtener todos los objetos que no tienen una propiedad específica?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

envuelva el objeto con java.util.Optional y luego use el método isPresent() para verificar

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!