'Why does Spring Data JPA SQL got error inserting my data

There are 3 entities, Customer, Account and Transaction

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Account {

    @Id
    private Long id;
}

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Customer {

    @Id
    private Long id;

}
@Entity
@Data
@NoArgsConstructor
public class Transaction {

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

    @ManyToOne(
            cascade = CascadeType.ALL
    )
    private Account accountNumber;
    private Double amount;
    private String desc;
    @Temporal(TemporalType.DATE)
    private Date date;
    @Temporal(TemporalType.TIME)
    private Date time;

    @ManyToOne(
            cascade = CascadeType.ALL
    )
    private Customer customer;

    public Transaction(Long accountNumber, Double amount, String desc, String date, String time, Long customer) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
        SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
        this.accountNumber = new Account(accountNumber);
        this.amount = amount;
        this.desc = desc;
        this.date = dateFormat.parse(date);
        this.time = timeFormat.parse(time);
        this.customer = new Customer(customer);
    }
}

I want to insert the data like below, I test this using main

@SpringBootApplication
public class ETellerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ETellerApplication.class, args);
    }

    @Bean
    PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }

    @Bean
    CommandLineRunner run(TransactionService transactionService){
        return args -> {
            
            transactionService.saveTransaction(new Transaction(8872838283L,
                    123.00,
                    "FUND TRANSFER",
                    "2019-09-12",
                    "11:11:11",
                    222L));

        };
    }


}

I get this error for running it.

2022-04-04 16:59:02.598  WARN 24444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1064, SQLState: 42000
2022-04-04 16:59:02.598 ERROR 24444 --- [  restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper   : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, time, id) values (8872838283, 123.0, 222, '2019-01-12', 'FUND TRANSFER', '' at line 1

The error above state about the SQL error but I can't understand the real error I can't process what happening here. I'm Spring Boot beginner and I did the Spring Boot tutorial but it is not enough. Please bear with me



Solution 1:[1]

It is my mistake to use DESC as the field name. I changed it to DESCRIPTION. Desc is reserverd keyword in SQL

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zakkir