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

750
Visualizações
Hibernate with long text column with Oracle and PostgreSQL

I'm trying make an entity work with Oracle (11.2) and PostgreSQL(9.4) in a Spring Boot (1.4.4) application.

My entity contains a long text field (over 4000 characters). The appropriate data type in Oracle is CLOB and the corresponding type in PostgreSQL is TEXT.

I'm able to make it work with PostgreSQL

@Column(name = "LONG_TEXT", columnDefinition="TEXT")
private String longText;

However it would fail with Oracle in hibernate validation stage since CLOB requires @Lob annotation.

The following code works with Oracle

@Lob
@Column(name = "LONG_TEXT")
private String longText;

However this time it fails when reading from PostgreSQL with the following exception:

PSQLException: Large Objects may not be used in auto-commit mode

Stack overflow suggests performing queries in transactions. Disregarding questionable requirement to invoke transaction in select queries, adding @Transactional to query methods didn't help.

Any thoughts are more than welcomed.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The solution we came to is to adopt the @Lob and @Transactional approach.

The main issue was with the placement of the @Transactional annotation, causing the PSQLException. Once fixed, we were able to work with both types of DBs.

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