我在使用spring boot应用程序和ms sl server db
执行存储过程时遇到了一些问题似乎正在更改列名 他是相关的代码
@Entity
public class StationComplianceStatus {
@Id
@Column(name="nID")
private Long id;
@Column(name="strResult")
private String result;
@Column(name="strStationType")
private String stationType;
@Column(name="strActiveUser")
private String activeUser;
//non ars constructor, getters setters
,实施是
StoredProcedureQuery query = em.createStoredProcedureQuery("my sp name as apprears in db", StationComplianceStatus.class);
query.registerStoredProcedureParameter(1, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(3, String.class, ParameterMode.IN);
query.setParameter(1, "");
query.setParameter(2, "");
query.setParameter(3, "");
query.execute();
log.debug(" after execution");
List<StationComplianceStatus> stationsStatus = query.getResultList();
我收到此错误
engine.jdbc.spi.SqlExceptionHelper:SQL错误:0,SQLState:S1093 engine.jdbc.spi.SqlExceptionHelper:列名str_active_user 无效。
我注意到列名已从strActiveUser更改为str_active_user,我相信这是问题的根源
答案 0 :(得分:1)
结果证明解决方案很简单,因为定义了以下属性
spring.jpa.hibernate.naming策略= org.hibernate.cfg.DefaultNamingStrategy
参考:https://github.com/spring-projects/spring-boot/issues/2129