Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
MongoDB avoid persisting some fields in POJO - Java

I’m trying to avoid persisting some fields in my POJO in to MongoDB.

I tried

1) Adding @javax.persistence.Transient on field.

2) Adding @org.springframework.data.annotation.Transient on field even i do not use spring at all.

3) Make the field transient

I am using Jakson as the default ObjectMapper of mongodb. and i am not using Spring data to interact with database

But no luck.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The issue is with javax.persistence.Transient But this one, which is a JPA annotation, will not work for MongoDB:

If you want you can use Spring framework @Transient annotation. Spring Documentation

import org.springframework.data.annotation.Transient;

I tried with Spring framework which is working fine for me.

Sample example

@Transient
    private Integer age;

If above solution not working the there might be an issue with MappingMongoConverter Annotation based mapping only works if you're using the MappingMongoConverter (Documentation) as backing converter for MongoTemplate. If you're not configuring the converter a SimpleMongoConverter will be used by default that simply serializes objects into Mongo without taking a look at any meta information whatsoever.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda