SpringBoot bug, that occurs when i try to insert a values into SQL "expense" table.
import java.time.Instant;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name="expense")
public class Expense {
@Id
private Long id;
private Instant expensedate;
private String description;
private String location;
@ManyToOne
private Category category;
@JsonIgnore
@ManyToOne
private User user1;
}
I have this expense.java (User and Category are also separate files) file and when i try to
insert into expense values (100,'New York Business Trip','2019-06-16T17:00:00.000Z','New York',1,1)
i get this error for some reason:
Cannot parse "TIMESTAMP WITH TIME ZONE" constant "New York Business Trip";
im pretty new at this, so explain it if you find a bug please. Thank you.
You are trying to pass a string value inside the Instant column, so that's why you are getting this issue.
insert into expense values (100, '2019-06-16T17:00:00.000Z', 'New York Business Trip', 'New York', 1, 1)
Not sure what's the inside the category class so you need to pass the value for it.