Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

380
Views
@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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!