予約語のサポートを高めるために春JPAテーブルのフィールド

たとえば:エンティティがあります

@data 
@Entity 
@Table(名 = "wx_user_storage" 
@ToString 
パブリック クラス UserStorageが実装シリアライズ{ 

    @Id 
    @GeneratedValue(戦略を = GenerationType.IDENTITYを)
    @Column(名 = "ID" プライベートロングID。
    @Column(名前 =「キー」プライベートキーの文字列。

}

ダオクラス

パブリック インターフェース UserStorageDaoは延び JpaRepository <UserStorage、ロング> { 
    @query( "キーUserStorage Sここs.key =から削除" 
    @Modifying(clearAutomatically = 
    @Transactional 
    空隙 clearUserKeys(@Param( "キー" )は、文字列キー) ; 
}

テストは以下のとおりです。

@RunWith(SpringRunner。クラス
@SpringBootTest(クラス = {DianliApplication。クラス }、webEnvironment = SpringBootTest.WebEnvironment.MOCK)
 パブリック クラスUserStorageDaoTest { 
    @Autowired 
    プライベートUserStorageDao userStorageDao。

    @Test 
    公共 ボイドTEST1(){ 
        userStorageDao.clearUserKeys( "キー" )。
    } 
}

application.yamlで次の設定を追加します。

春:
  JPA:
    プロパティ:
      休止状態:
        globally_quoted_identifiers:真

結果の実装:

:Hibernateは削除 から `wx_user_storage` ` キー ` =

提案と一致して

おすすめ

転載: www.cnblogs.com/linphy/p/11274165.html