Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda