【问题标题】:Play! Generic model conflict with blob data type玩!通用模型与 blob 数据类型冲突
【发布时间】:2012-10-05 13:57:17
【问题描述】:

我正在尝试将 extends GenericModel 与 blob 数据类型一起使用,但出现错误:

Execution error occured in template 
{module:crud}/app/views/tags/crud/form.html. Exception raised was 
MissingPropertyException : No such property: id for class: models.Member.
In {module:crud}/app/views/tags/crud/form.html (around line 56)

#{crud.passwordField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
#{/if}
#{if field.type == 'binary'}
    #{crud.fileField name:field.name, value:(currentObject ? currentObject[field.name] : null), id:currentObject?.id /}
#{/if}
#{if field.type == 'longtext'}
    #{crud.longtextField name:field.name, value:(currentObject ? currentObject[field.name] : null) /}
#{/if}

我的模型是:

@Entity
@Table(name = "news_feed")
public class NewsFeed extends GenericModel {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long news_id;

    public Blob news_image;
    ...
}

如果我删除 extends GenericModel 或删除 blob,我不会收到错误消息。是什么导致了问题?

欢迎所有帮助。

谢谢!

【问题讨论】:

    标签: jpa playframework blob playframework-1.x


    【解决方案1】:

    我认为您的问题不在于 blob,而是 CRUD 模块处理非标准 id 名称。

    在您的示例中,crud 模块尝试获取“currentObject?.id”,但您的 id 名称是“news_id”

    尝试将“news_id”字段重命名为“id”

    【讨论】:

    • 这不是应该由@Id 解决的吗?不过它确实有效,谢谢!
    • @Id 将您的属性设置为 jpa 持久性的 id,但 CRUD 模块适用于比 jpa 更严格的约定
    猜你喜欢
    • 2021-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 2017-04-18
    • 1970-01-01
    相关资源
    最近更新 更多