I am using a JPA repository to save the entity to database
Table is something like this. CREATE TABLE IF NOT EXISTS Data_Catalog( F_Id bigint auto_increment primary key, Name varchar(500), Age int );
java entity
@Entity
@AllArgsConstructor
@Table(name = "Data_Catalog")
@Getter
@Setter
public class Data {
@Id
@Column(name = "F_Id")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long fid;
@Column(name = "Name")
private Sting name;
@Column(name = "Age")
private int name;
}
method that is giving me the exception. is DataRepository.saveAll(datalist); //note this method gets called by Mutiple threads
@Repository
public interface DataRepository extends JpaRepository\<DataCatalog, Long\> {}
error i am getting is 2023-03-27 23:10:40 2023-03-27 17:40:40.283 WARN 15 --- [ 7] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1205, SQLState: 40001 2023-03-27 23:10:40 2023-03-27 17:40:40.283 ERROR 15 --- [ 7] o.h.engine.jdbc.spi.SqlExceptionHelper : Lock wait timeout exceeded; try restarting transaction 2023-03-27 23:10:40 Caused by org.hibernate.PessimisticLockException: could not execute statement
i tried using @Version annotation to a new field something like this.
@version
int version;
in the entity class
yet i get the same error. please help me!!!!!