HSQLException on session.list. Error: Unexpected token "Entity name"
HSQLException on session.list. Error: Unexpected token "Entity name"
我正在为其中一个项目设置 hibernate/JPA,但 运行 遇到了奇怪的错误。
每当我尝试调用 session.list() 时,我首先会收到以下警告。
6565 [main] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: -5581, SQLState: 42581
在此之后,我收到以下错误。
意外标记:ADSUBCONTE8_
详细的堆栈跟踪:-
org.hibernate.exception.SQLGrammarException: could not prepare statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:159)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1858)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1835)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1815)
at org.hibernate.loader.Loader.doQuery(Loader.java:899)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
at org.hibernate.loader.Loader.doList(Loader.java:2522)
at org.hibernate.loader.Loader.doList(Loader.java:2508)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2338)
at org.hibernate.loader.Loader.list(Loader.java:2333)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:124)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1662)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: ADSUBCONTE8_
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.doPrepare(StatementPreparerImpl.java:161)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182)
... 49 more
Caused by: org.hsqldb.HsqlException: unexpected token: ADSUBCONTE8_
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleValueExpressionPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesValueExpressionPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesFactor(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesCommonValueExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadValueExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 55 more
多对一关系中两个 class 的 java class 如下(突出显示感兴趣的行)
/**
* The persistent class for the ad_context_tags database table.
*
*/
@Entity
@Table(name = "ad_context_tags")
@NamedQuery(name = "AdContextTagEntity.findAll", query = "SELECT a FROM AdContextTagEntity a")
public class AdContextTagEntity implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(unique = true, nullable = false)
private int id;
@Column(name = "created_by", nullable = false, length = 100)
private String createdBy;
@Temporal(TemporalType.DATE)
@Column(name = "creation_date", nullable = false)
private Date creationDate;
@Temporal(TemporalType.DATE)
@Column(name = "last_update_date")
private Date lastUpdateDate;
// bi-directional many-to-one association to AdCategoryEntity
@ManyToOne
@JoinColumn(name = "category", nullable = false)
private AdCategoryEntity adCategory;
// bi-directional many-to-one association to AdPageInfoEntity
@ManyToOne
@JoinColumn(name = "page_info", nullable = false)
private AdPageInfoEntity adPageInfo;
// bi-directional many-to-one association to AdSlotFamilyEntity
@ManyToOne
@JoinColumn(name = "`slot_group`", nullable = false)
private AdSlotFamilyEntity adSlotFamily;
// bi-directional many-to-one association to MarketplaceMappingEntity
@ManyToOne
@JoinColumn(name = "siterealm")
private LegacyMarketplaceMappingEntity marketplaceMapping;
// ========== the field that gives the error below. Class defined later in the post ======
@ManyToOne
@JoinColumn(name = "subcontext")
private AdSubcontextEntity subcontextEntity;
public AdSubcontextEntity getSubcontextEntity()
{
return subcontextEntity;
}
public void setSubcontextEntity(AdSubcontextEntity subcontextEntity)
{
this.subcontextEntity = subcontextEntity;
}
public AdContextTagEntity()
{
}
public int getId()
{
return this.id;
}
public void setId(int id)
{
this.id = id;
}
public String getCreatedBy()
{
return this.createdBy;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public Date getCreationDate()
{
return this.creationDate;
}
public void setCreationDate(Date creationDate)
{
this.creationDate = creationDate;
}
public Date getLastUpdateDate()
{
return this.lastUpdateDate;
}
public void setLastUpdateDate(Date lastUpdateDate)
{
this.lastUpdateDate = lastUpdateDate;
}
public AdCategoryEntity getAdCategory()
{
return this.adCategory;
}
public void setAdCategory(AdCategoryEntity adCategory)
{
this.adCategory = adCategory;
}
public AdPageInfoEntity getAdPageInfo()
{
return this.adPageInfo;
}
public void setAdPageInfo(AdPageInfoEntity adPageInfo)
{
this.adPageInfo = adPageInfo;
}
public AdSlotFamilyEntity getAdSlotFamily()
{
return this.adSlotFamily;
}
public void setAdSlotFamily(AdSlotFamilyEntity adSlotFamily)
{
this.adSlotFamily = adSlotFamily;
}
public LegacyMarketplaceMappingEntity getMarketplaceMapping()
{
return this.marketplaceMapping;
}
public void setMarketplaceMapping(LegacyMarketplaceMappingEntity marketplaceMapping)
{
this.marketplaceMapping = marketplaceMapping;
}
public DcAdLocation constructSerializable()
{
// TODO Auto-generated method stub
return new DcAdLocation();
}
}
有问题的 class 如下:-
@Entity
@Table(name="ad_subcontext")
@NamedQuery(name="AdSubcontextEntity.findAll", query="SELECT a FROM AdSubcontextEntity a")
public class AdSubcontextEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(unique=true, nullable=false)
private int id;
@Column(nullable=false, length=20)
private String primary;
@Column(length=11)
private String secondary;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getPrimary() {
return this.primary;
}
public void setPrimary(String primary) {
this.primary = primary;
}
public String getSecondary() {
return this.secondary;
}
public void setSecondary(String secondary) {
this.secondary = secondary;
}
}
hibernate生成的SQL如下:-
/**
* select this_.id as id1_6_7_, this_.category as category5_6_7_,
* this_.page_info as page6_6_7_, this_."slot_group" as slot7_6_7_,
* this_.created_by as created2_6_7_, this_.creation_date as creation3_6_7_,
* this_.foo as foo8_6_7_, this_.last_update_date as last4_6_7_, this_.siterealm
* as sitereal9_6_7_, adcategory2_.id as id1_3_0_, adcategory2_.name as
* name2_3_0_, adpageinfo3_.id as id1_8_1_, adpageinfo3_.page_family as
* page5_8_1_, adpageinfo3_.browse_node as browse2_8_1_, adpageinfo3_.page_name
* as page3_8_1_, adpageinfo3_.page_short_name as page4_8_1_, adpageamab4_.id as
* id1_7_2_, adpageamab4_.amabotId as amabotId2_7_2_, adpageamab4_.family as
* family3_7_2_, adslotfami5_.id as id1_12_3_, adslotfami5_."slot_family_name"
* as slot2_12_3_, foo6_.id as id1_0_4_, foo6_.primary as primary2_0_4_,
* foo6_.secondary as secondar3_0_4_, legacymark7_.id as id1_24_5_,
* legacymark7_.client_id as client4_24_5_, legacymark7_.client_zone as
* client2_24_5_, legacymark7_.marketplace_id as marketpl3_24_5_,
* legacyclie8_.id as id1_19_6_, legacyclie8_.client_name as client2_19_6_ from
* ad_context_tags this_ inner join ad_category adcategory2_ on
* this_.category=adcategory2_.id inner join ad_page_info adpageinfo3_ on
* this_.page_info=adpageinfo3_.id left outer join ad_page_amabot_mapping
* adpageamab4_ on adpageinfo3_.page_family=adpageamab4_.id inner join
* ad_slot_family adslotfami5_ on this_."slot_group"=adslotfami5_.id inner join
* Foo foo6_ on this_.foo=foo6_.id left outer join marketplace_mappings
* legacymark7_ on this_.siterealm=legacymark7_.id left outer join clients
* legacyclie8_ on legacymark7_.client_id=legacyclie8_.id
*/
我自己也做了一些调查,看起来这个 ADSUBCONTE8 无论如何都会生成。我尝试将其重命名为 Crap.java 但随后我不断收到错误消息,作为意外标记 Crap6。
如果我尝试从父 AdContextTagEntity 中删除 AdSubContext,测试和构建会顺利通过。
请帮助我,因为我真的被困在这个问题上了。
看起来 SQL 是由您提供的,没有 "subcontextEntity" 字段,因为它不包含到 table ad_subcontext 的连接。
异常不在Hibernate中,而是在HSQLDB驱动中。因此,由于某些原因,驱动程序无法解析 SQL。
可能的原因:
使用"primary"、"secondary"作为字段名——这个名字可以为主键和副键保留。
在
中使用奇怪的名称“`slot_group`”
@JoinColumn(name = "`slot_group`", nullable = false)
或其他 "field name" 原因。
首先你是对的,警告和异常是相互关联的。警告和异常都指向指定的意外标记 here。
异常不在 Hibernate 中,但可能在 HSQLDB.The 子查询中似乎是问题所在。 Hsqldb 似乎无法解析子 queries.Some 我们可以尝试的东西。(如果您已经尝试过,我们深表歉意)
- 尝试更改
primary
和 secondary
的列名称。基本上检查保留字,因为在命名中使用保留字时可能会出现此错误。
- 检查你的 SQL 文件是否在独立模式下正确执行,并创建所有具有所有预期约束的表,特别是与
ad_subcontext
table.Saying 有关,因为在您添加为问题的生成查询。在您的数据库上尝试类似的 SQL 我很确定它会出现类似的错误。
我正在为其中一个项目设置 hibernate/JPA,但 运行 遇到了奇怪的错误。
每当我尝试调用 session.list() 时,我首先会收到以下警告。
6565 [main] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: -5581, SQLState: 42581
在此之后,我收到以下错误。
意外标记:ADSUBCONTE8_
详细的堆栈跟踪:-
org.hibernate.exception.SQLGrammarException: could not prepare statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:159)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1858)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1835)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1815)
at org.hibernate.loader.Loader.doQuery(Loader.java:899)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
at org.hibernate.loader.Loader.doList(Loader.java:2522)
at org.hibernate.loader.Loader.doList(Loader.java:2508)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2338)
at org.hibernate.loader.Loader.list(Loader.java:2333)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:124)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1662)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: ADSUBCONTE8_
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.doPrepare(StatementPreparerImpl.java:161)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182)
... 49 more
Caused by: org.hsqldb.HsqlException: unexpected token: ADSUBCONTE8_
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleValueExpressionPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesValueExpressionPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesFactor(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesCommonValueExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadValueExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 55 more
多对一关系中两个 class 的 java class 如下(突出显示感兴趣的行)
/**
* The persistent class for the ad_context_tags database table.
*
*/
@Entity
@Table(name = "ad_context_tags")
@NamedQuery(name = "AdContextTagEntity.findAll", query = "SELECT a FROM AdContextTagEntity a")
public class AdContextTagEntity implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(unique = true, nullable = false)
private int id;
@Column(name = "created_by", nullable = false, length = 100)
private String createdBy;
@Temporal(TemporalType.DATE)
@Column(name = "creation_date", nullable = false)
private Date creationDate;
@Temporal(TemporalType.DATE)
@Column(name = "last_update_date")
private Date lastUpdateDate;
// bi-directional many-to-one association to AdCategoryEntity
@ManyToOne
@JoinColumn(name = "category", nullable = false)
private AdCategoryEntity adCategory;
// bi-directional many-to-one association to AdPageInfoEntity
@ManyToOne
@JoinColumn(name = "page_info", nullable = false)
private AdPageInfoEntity adPageInfo;
// bi-directional many-to-one association to AdSlotFamilyEntity
@ManyToOne
@JoinColumn(name = "`slot_group`", nullable = false)
private AdSlotFamilyEntity adSlotFamily;
// bi-directional many-to-one association to MarketplaceMappingEntity
@ManyToOne
@JoinColumn(name = "siterealm")
private LegacyMarketplaceMappingEntity marketplaceMapping;
// ========== the field that gives the error below. Class defined later in the post ======
@ManyToOne
@JoinColumn(name = "subcontext")
private AdSubcontextEntity subcontextEntity;
public AdSubcontextEntity getSubcontextEntity()
{
return subcontextEntity;
}
public void setSubcontextEntity(AdSubcontextEntity subcontextEntity)
{
this.subcontextEntity = subcontextEntity;
}
public AdContextTagEntity()
{
}
public int getId()
{
return this.id;
}
public void setId(int id)
{
this.id = id;
}
public String getCreatedBy()
{
return this.createdBy;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public Date getCreationDate()
{
return this.creationDate;
}
public void setCreationDate(Date creationDate)
{
this.creationDate = creationDate;
}
public Date getLastUpdateDate()
{
return this.lastUpdateDate;
}
public void setLastUpdateDate(Date lastUpdateDate)
{
this.lastUpdateDate = lastUpdateDate;
}
public AdCategoryEntity getAdCategory()
{
return this.adCategory;
}
public void setAdCategory(AdCategoryEntity adCategory)
{
this.adCategory = adCategory;
}
public AdPageInfoEntity getAdPageInfo()
{
return this.adPageInfo;
}
public void setAdPageInfo(AdPageInfoEntity adPageInfo)
{
this.adPageInfo = adPageInfo;
}
public AdSlotFamilyEntity getAdSlotFamily()
{
return this.adSlotFamily;
}
public void setAdSlotFamily(AdSlotFamilyEntity adSlotFamily)
{
this.adSlotFamily = adSlotFamily;
}
public LegacyMarketplaceMappingEntity getMarketplaceMapping()
{
return this.marketplaceMapping;
}
public void setMarketplaceMapping(LegacyMarketplaceMappingEntity marketplaceMapping)
{
this.marketplaceMapping = marketplaceMapping;
}
public DcAdLocation constructSerializable()
{
// TODO Auto-generated method stub
return new DcAdLocation();
}
}
有问题的 class 如下:-
@Entity
@Table(name="ad_subcontext")
@NamedQuery(name="AdSubcontextEntity.findAll", query="SELECT a FROM AdSubcontextEntity a")
public class AdSubcontextEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(unique=true, nullable=false)
private int id;
@Column(nullable=false, length=20)
private String primary;
@Column(length=11)
private String secondary;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getPrimary() {
return this.primary;
}
public void setPrimary(String primary) {
this.primary = primary;
}
public String getSecondary() {
return this.secondary;
}
public void setSecondary(String secondary) {
this.secondary = secondary;
}
}
hibernate生成的SQL如下:-
/**
* select this_.id as id1_6_7_, this_.category as category5_6_7_,
* this_.page_info as page6_6_7_, this_."slot_group" as slot7_6_7_,
* this_.created_by as created2_6_7_, this_.creation_date as creation3_6_7_,
* this_.foo as foo8_6_7_, this_.last_update_date as last4_6_7_, this_.siterealm
* as sitereal9_6_7_, adcategory2_.id as id1_3_0_, adcategory2_.name as
* name2_3_0_, adpageinfo3_.id as id1_8_1_, adpageinfo3_.page_family as
* page5_8_1_, adpageinfo3_.browse_node as browse2_8_1_, adpageinfo3_.page_name
* as page3_8_1_, adpageinfo3_.page_short_name as page4_8_1_, adpageamab4_.id as
* id1_7_2_, adpageamab4_.amabotId as amabotId2_7_2_, adpageamab4_.family as
* family3_7_2_, adslotfami5_.id as id1_12_3_, adslotfami5_."slot_family_name"
* as slot2_12_3_, foo6_.id as id1_0_4_, foo6_.primary as primary2_0_4_,
* foo6_.secondary as secondar3_0_4_, legacymark7_.id as id1_24_5_,
* legacymark7_.client_id as client4_24_5_, legacymark7_.client_zone as
* client2_24_5_, legacymark7_.marketplace_id as marketpl3_24_5_,
* legacyclie8_.id as id1_19_6_, legacyclie8_.client_name as client2_19_6_ from
* ad_context_tags this_ inner join ad_category adcategory2_ on
* this_.category=adcategory2_.id inner join ad_page_info adpageinfo3_ on
* this_.page_info=adpageinfo3_.id left outer join ad_page_amabot_mapping
* adpageamab4_ on adpageinfo3_.page_family=adpageamab4_.id inner join
* ad_slot_family adslotfami5_ on this_."slot_group"=adslotfami5_.id inner join
* Foo foo6_ on this_.foo=foo6_.id left outer join marketplace_mappings
* legacymark7_ on this_.siterealm=legacymark7_.id left outer join clients
* legacyclie8_ on legacymark7_.client_id=legacyclie8_.id
*/
我自己也做了一些调查,看起来这个 ADSUBCONTE8 无论如何都会生成。我尝试将其重命名为 Crap.java 但随后我不断收到错误消息,作为意外标记 Crap6。 如果我尝试从父 AdContextTagEntity 中删除 AdSubContext,测试和构建会顺利通过。
请帮助我,因为我真的被困在这个问题上了。
看起来 SQL 是由您提供的,没有 "subcontextEntity" 字段,因为它不包含到 table ad_subcontext 的连接。
异常不在Hibernate中,而是在HSQLDB驱动中。因此,由于某些原因,驱动程序无法解析 SQL。
可能的原因:
使用"primary"、"secondary"作为字段名——这个名字可以为主键和副键保留。
在
中使用奇怪的名称“`slot_group`”@JoinColumn(name = "`slot_group`", nullable = false)
或其他 "field name" 原因。
首先你是对的,警告和异常是相互关联的。警告和异常都指向指定的意外标记 here。
异常不在 Hibernate 中,但可能在 HSQLDB.The 子查询中似乎是问题所在。 Hsqldb 似乎无法解析子 queries.Some 我们可以尝试的东西。(如果您已经尝试过,我们深表歉意)
- 尝试更改
primary
和secondary
的列名称。基本上检查保留字,因为在命名中使用保留字时可能会出现此错误。 - 检查你的 SQL 文件是否在独立模式下正确执行,并创建所有具有所有预期约束的表,特别是与
ad_subcontext
table.Saying 有关,因为在您添加为问题的生成查询。在您的数据库上尝试类似的 SQL 我很确定它会出现类似的错误。