jingkaimori
V2EX  ›  Java

如果数据库字段名含有_and, jpa 能正常生成代码吗

  •  
  •   jingkaimori ·
    jingkaimori · Jul 15, 2021 · 1807 views
    This topic created in 1772 days ago, the information mentioned may be changed or developed.

    比如以下数据库映射:

    @Entity
    @Table(name = "user")
    @Data
    public class Data{
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id")
        private Integer id;
    
        @Column(name = "_and")
        private String And;
    }
    
    public interface DataRepository extends JpaRepository<Data, Integer>, JpaSpecificationExecutor<Data> {
        
        Data findDataByAnd(String and);
    }
    
    Pengcl
        1
    Pengcl  
       Jul 19, 2021
    ```
    @Column(name = "`_and`")
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   915 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 19:58 · PVG 03:58 · LAX 12:58 · JFK 15:58
    ♥ Do have faith in what you're doing.