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

382
Visualizações
@SqlDelete bigint to timestamp

I am trying to soft delete row from a database by id. When I do DELETE localhost:8080/id (using postman) I get sql exception: org.postgresql.util.PSQLException: ERROR: column "deleted_at" is of type bigint but expression is of type timestamp with time zone

My RequestMapping looks like:

@RequestMapping (value = "/{id}", method = RequestMethod.DELETE)
public String delete (@PathVariable Long id){
    Class class = classRepository.findOne(id);
    class.setDeletedAt(System.currentTimeMillis()/1000);
    classRepository.delete(class);

    return "\"OK\"";
}

Entity:

@Entity
@SQLDelete(sql = "UPDATE class SET deleted_at = now() where id = ?")
@Where(clause="deleted_at is NULL")
public class Class extends SoftDeleteableEntity {


private String name;
private String address;

// setters and getters
}

SoftDelete:

public abstract class SoftDeleteableEntity extends BaseEntity {

protected Long deletedAt;

// setters and getters
}

BaseEntity:

@MappedSuperclass
public abstract class BaseEntity implements Serializable{

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

public void setId(Long id) {
    this.id = id;
}
} 

Class Repository interface extends JpaRepository with no code and @Component annotation. ClassService class is with @Service annotation that only @Autowires repository.

I have tried using classRepository.save(class) instead of delete but then i can't get the data to be saved to database.

I have been searching the forums for a solution but can't seem to find one. Any help or tips would be appreciated.

P.S. I'm new to programming (learning spring for 2 weeks) and I'm sorry if I have missed some existing answer on stackoverflow or asked something the wrong way.

over 4 years ago · Santiago Trujillo
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