Sql server 带Hibernate的SQL Server方言
我在CRUD层和ORM项目中使用了hibernate支持的spring数据。我先用H2。但在切换到SQL server 2014时,我面临以下问题: 我使用以下服务:Sql server 带Hibernate的SQL Server方言,sql-server,hibernate,spring-data,Sql Server,Hibernate,Spring Data,我在CRUD层和ORM项目中使用了hibernate支持的spring数据。我先用H2。但在切换到SQL server 2014时,我面临以下问题: 我使用以下服务: @Query("Select example from Example example where example.exampleProperty like CONCAT('%',:param,'%')") List<Example> findByProductLibe(@Param("param") Stri
@Query("Select example from Example example where
example.exampleProperty like CONCAT('%',:param,'%')")
List<Example> findByProductLibe(@Param("param") String param);
问题在于“|”字符,它在“|”附近打印“不正确的语法”
以下是我的数据库配置:
database.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
database.password =
database.username =
hibernate.dialect = org.hibernate.dialect.SQLServerDialect
hibernate.ejb.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
hibernate.hbm2ddl.auto = create
hibernate.generate_statistics = true
hibernate.format_sql = true
hibernate.show_sql = true
感谢您的帮助或指示。用以下代码替换回购协议应该有效
@Query("Select example from Example example where
example.exampleProperty like %:param%")
List<Example> findByProductLibe(@Param("param") String param);
@Query(“从示例中选择示例,其中
example.example属性(如%:param%))
列出findByProductLibe(@Param(“Param”)字符串Param);
谢谢您的回答,问题终于解决了,我将hibernate.dial设置为org.hibernate.dial.SQLServer2012Dialect,它生成了以下查询:
Hibernate:
select
ex.param1 as param1,
ex.param2 as param2
from
example ex
where example.exampleProperty like ('%'+?+'%')
我一定没有清洁和安装项目正确
谢谢。请添加您的Hibernate配置。
Hibernate:
select
ex.param1 as param1,
ex.param2 as param2
from
example ex
where example.exampleProperty like ('%'+?+'%')