I am working on Spring Data JPA + Postgres lombok example. In this example I am getting below error.
java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:782) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:763) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    at org.example.StockApplication.main(StockApplication.java:18) [classes/:na]
Caused by: java.lang.UnsupportedOperationException: null
    at java.util.AbstractCollection.add(AbstractCollection.java:262) ~[na:1.8.0_171]
    at org.hibernate.collection.internal.PersistentSet.add(PersistentSet.java:211) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
    at org.example.StockApplication.run(StockApplication.java:40) [classes/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
    ... 5 common frames omitted
Stock.java
@Builder
@Getter
@AllArgsConstructor
@Entity
@Table(name = "stock", catalog = "mkyongdb", uniqueConstraints = { @UniqueConstraint(columnNames = "STOCK_NAME"),
        @UniqueConstraint(columnNames = "STOCK_CODE") })
public class Stock implements java.io.Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "STOCK_ID", unique = true, nullable = false)
    private Integer stockId;
    @Column(name = "STOCK_CODE", unique = true, nullable = false, length = 10)
    private String stockCode;
    @Column(name = "STOCK_NAME", unique = true, nullable = false, length = 20)
    private String stockName;
    @Singular
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "stock")
    private final Set<StockDailyRecord> stockDailyRecords;
}
StockDailyRecord.java
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "stock_daily_record", catalog = "mkyongdb", uniqueConstraints = @UniqueConstraint(columnNames = "DATE"))
public class StockDailyRecord implements java.io.Serializable {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "RECORD_ID", unique = true, nullable = false)
    private Integer recordId;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STOCK_ID", nullable = false)
    private Stock stock;
    @Column(name = "PRICE_OPEN", precision = 6)
    private Float priceOpen;
    @Column(name = "PRICE_CLOSE", precision = 6)
    private Float priceClose;
    @Column(name = "PRICE_CHANGE", precision = 6)
    private Float priceChange;
    @Column(name = "VOLUME")
    private Long volume;
    @Temporal(TemporalType.DATE)
    @Column(name = "DATE", unique = true, nullable = false, length = 10)
    private Date date;
}
Main.App
@SpringBootApplication
public class StockApplication implements CommandLineRunner{
    public static void main(String[] args) {
        SpringApplication.run(StockApplication.class, args);
    }
    @Autowired
    private StockRepository stockRepository;
    @Autowired
    private StockDailyRecordRepository stockDailyRecordRepository;
    @Override
    public void run(String... args) throws Exception {
        Stock stock = Stock.builder().stockCode("7052").stockName("PADINI").build();
        stockRepository.save(stock);
        StockDailyRecord stockDailyRecords = StockDailyRecord.builder()
                .priceOpen(new Float("1.2"))
                .priceChange(new Float("10.0"))
                .priceClose(new Float("1.1"))
                .date(new Date())
                .volume(3000000L)
                .build();
        stockDailyRecords.setStock(stock);        
        stock.getStockDailyRecords().add(stockDailyRecords); //Line-22
        stockDailyRecordRepository.save(stockDailyRecords);
    }
}
Note: Code is breaking at line-22