英文:
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelpe / org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL
问题
以下是运行时生成的JPA查询:select m1_0.Patient_Id,m1_0.PLN_ID from [DevDatabase.dbo].Users m1_0 where m1_0.Patient_Id=?
实体类:
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Table(name = "Users", schema = "DevDatabase.dbo")
public class MemberDetailsEntity
{
@Id
@NonNull
@Column(name = "Patient_Id")
private String PatientId;
@Column(name = "PLN_ID")
private String planId;
}
在迁移到Java 17后,我发现自动生成的查询在模式名称(DEVDATABASE.DBO)的开头和结尾添加了方括号,但它应该像这样添加:[DEVDATABASE].[DBO]或者不添加它们。因此,查询在MSSQL中执行失败,抛出以下错误:
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Invalid object name DevDatabase.dbo.Users
或
org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL DevDatabase.dbo.Users
如何解决这个问题?
我尝试升级和降级Hibernate版本,但没有帮助。
所有建议的注解添加都已经完成,但问题仍未解决。
英文:
Below is the :
JPA Query generated at runtime: select m1_0.Patient_Id,m1_0.PLN_ID from [DevDatabase.dbo].Users m1_0 where m1_0.Patient_Id=?
ENTITY class:
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Table(name = "Users", schema = "DevDatabase.dbo")
public class MemberDetailsEntity
{
@Id
@NonNull
@Column(name = "Patient_Id")
private String PatientId;
@Column(name = "PLN_ID")
private String planId;
}
After migrating to java 17, I see that the autogenerated query happens to add square brackets to the schema name (DEVDATABASE.DBO) at the beginning and the end, but it should either add like this
[DEVDATABASE].[DBO] or not add them. Because of it, the query fails to execute in mssql ad it throws
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Invalid object name DevDatabase.dbo.Users
or
org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL DevDatabase.dbo.Users
How can this issue be resolved ?
I tried upgrading and downgrading the hibernate version. But nothing helped.
All recommended annotations additions to the entity class is already done yet not resolved.
答案1
得分: 0
@Table(name = "Users", catalog = "DevDatabase", schema = "dbo")
英文:
Perhaps you meant to write:
@Table(name = "Users", catalog = "DevDatabase", schema = "dbo")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论