gpt4 book ai didi

hibernate - Grails GORM映射尝试访问不存在的字段 “class”

转载 作者:行者123 更新时间:2023-12-02 14:46:54 24 4
gpt4 key购买 nike

这很奇怪。

class Service implements Serializable{

Integer id
String serviceName
String description
SortedSet serviceRequirements

static hasMany = [ serviceRequirements : ServiceRequirement]

static mapping =
{
table 'service'

columns {
id column:'serviceId'

}
}}

访问serviceInstance.serviceRequirements时生成的休眠sql为:
  servicereq0_.serviceId as serviceId1_,
servicereq0_.serviceRequirementId as serviceR1_1_,
servicereq0_.serviceRequirementId as serviceR1_9_0_,
servicereq0_.version as version9_0_,
servicereq0_.description as descript3_9_0_,
servicereq0_.header as header9_0_,
servicereq0_.isPersonal as isPersonal9_0_,
servicereq0_.requirementKey as requirem6_9_0_,
servicereq0_.required as required9_0_,
servicereq0_.serviceId as serviceId9_0_,
servicereq0_.type as type9_0_,
servicereq0_.weight as weight9_0_,
servicereq0_.oauthAccessTokenUrl as oauthAc12_9_0_,
servicereq0_.oauthAuthorizeAdditionalParameters as oauthAu13_9_0_,
servicereq0_.oauthAuthorizeState as oauthAu14_9_0_,
servicereq0_.oauthAuthorizeUrl as oauthAu15_9_0_,
servicereq0_.oauthClientId as oauthCl16_9_0_,
servicereq0_.oauthClientSecret as oauthCl17_9_0_,
servicereq0_.oauthRequestTokenUrl as oauthRe18_9_0_,
servicereq0_.oauthType as oauthType9_0_,
servicereq0_.class as class9_0_

除了最后一个“类”,所有字段都可以。它在数据库或称为ServiceRequirement的域类中根本不存在。

最佳答案

当列class存储多个类时,该列会自动添加到表中。如果ServiceRequirement类具有也是域类的子类,则该表将需要class列来知道它是哪种ServiceRequirement。如果设置了dbCreate,Grails通常很聪明,可以自动添加该列,但是如果您手动管理模式,则需要自己添加。

关于hibernate - Grails GORM映射尝试访问不存在的字段 “class”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7402310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com