gpt4 book ai didi

java - 如何使用注释存储时将实体类中的列值设为小写

转载 作者:行者123 更新时间:2023-12-02 00:22:21 25 4
gpt4 key购买 nike

I want an entity class through which I can store data to DB, for specific columns I want in case-sensitive, is there any annotation to be used above these specific columns to store as requested? please let me if the question is not clear,Thanks in advance.

@Column(name = "EMAIL",unique=true)  //i want store this email id as lower case,
private String email; //never mind in what case user enters

最佳答案

您可以使用@ColumnTransformer来做到这一点

 @Column(name = "email") 
@ColumnTransformer(write = "LOWER(email)")
private String email;

关于java - 如何使用注释存储时将实体类中的列值设为小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58072890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com