Reputation: 1717
@Entity
@Table(name = "DISC")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(of = { "discId" })
public class Disc implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@ReturnInsert
@Column(name = "DISC_ID")
private Long discId;
..
}
and
@Repository
public interface DiscRepository extends JpaRepository<Disc, Long> {
...
}
but when I save using saveAndFlush() I have this error:
org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save():
Upvotes: 0
Views: 572
Reputation: 5786
Looks like you don't set the discId
field, as simple as that.
If you want to delegate this to the framework use @GeneratedValue
(and set strategy which corresponds to your DB). The framework will handle the ids generation for you.
Upvotes: 1