Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore field for update in spring-r2dbc

I am using spring r2dbc and ReactiveCrudRepository, I have a field which I need to ignore for when update query is generated

@Data
@Table(PRODUCT_TABLE)
public class ProductEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO) // Id generated by database
    private Integer id;

    private Integer companyId;

    @Column(insertable=false, updatable = false)
    private String companyName;

    @NotBlank
    private String name;

    private VerificationStatus verificationStatus;
}

How can I ignore companyName in update query. I am able ignore it in insert query using @column but its not working for update

like image 777
Rachana Kulkarni Avatar asked Nov 16 '22 11:11

Rachana Kulkarni


1 Answers

If you don't want to keep the field for update and insert, then mark the field with @Transient.

For example,

@Transient
private String companyName;

https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/annotation/Transient.html

like image 57
Dharmendra Vishwakarma Avatar answered Dec 16 '22 19:12

Dharmendra Vishwakarma