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

383
Vistas
@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 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