如何解决Coldfusion ORM 持久性实体中未识别属性
<cfcomponent persistent="true" table="MENU_recipeTypes" entityname="recipeTypes" >
<cfproperty name="id" fieldtype="id" column="recipeType_id" generator="native" setter="false">
<cfproperty name="name" column="recipeType_name" type="string">
<cfproperty name="recipeType_help" column="recipeType_help" type="string">
<cfproperty name="hasPrice" column="hasPrice" type="binary">
<cfproperty name="recipeTypeOrder" type="numeric">
<cfproperty name="exclusiveType" type="binary">
<cfproperty name="recipe" fieldtype="one-to-many" cfc="recipes" fkcolumn="recipeType_id" type="array">
<cfproperty name="recipeTypedisplay" fieldtype="one-to-many" cfc="recipeTypedisplay" fkcolumn="recipeType_id" type="array">
</cfcomponent>
在我运行 Windows 10 和 sql Express 2017 和 CF2018 的本地机器上,一切运行顺利。但是,在运行带有 sql Express 2019 和 CF2021 的 Windows Server 2019 Datacenter 的服务器上,由于某种原因找不到属性“hasPrice”。
我完全不知道为什么会发生这种情况。
测试:
<cfset thisRecipeType = entityLoadByPK("recipeTypes",5)>
<cfdump var="#thisRecipeType#">
结果:
数据库中的数据:
因此实体 5 的 hasPrice 列中显然有一个值。
ADDENDUM:似乎 MSsql2017 接受类型“位”或“二进制”作为布尔值的有效类型,但 MSsql2019 不接受任何一种,只接受布尔值。这不会导致错误,而是返回“未定义值”。
解决方法
问题是 hasPrice 属性有 type="binary"
。在 ColdFusion 中,true/false 属性应具有 type="boolean"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。