我有一个查询
public void saveReportId(BigDecimal reportId) {
entityManager.createQuery("UPDATE ReportEntity r set r.report_id = reportId WHERE s.phase = :phase")
.setParameter("reportId", reportId)
.setParameter("phase", ReportStatus.NEW.getValue())
.executeUpdate();
}
但是,没有使用我在参数中传递的reportId值填充表,而是出现了错误:
Problem compiling - The state field cannot be resolved.
答案 0 :(得分:1)
缺少:reportId
,也将s.phase
替换为r.phase
。只需更新即可:
entityManager.createQuery("update ReportEntity r set r.report_id = :reportId where r.phase = :phase")
.setParameter("reportId", reportId)
.setParameter("phase", ReportStatus.NEW.getValue())
.executeUpdate();
希望这会有所帮助:)
答案 1 :(得分:1)
在您的命名参数查询中,您可能会想念您遵循规则reportId
。
因此,就您而言,只需注意entityManager.createQuery("UPDATE ReportEntity r set r.report_id = :reportId WHERE s.phase = :phase")
参数。只需这样更改第二个:
function create_collaborations()
{
register_post_type('collaborations',
array('labels' => array('name' => __('collaborations'),'singular_name' => __('Collaborations')),'public' => true,'has_archive' => false,'rewrite' => array('slug' => 'collaborations'))
);
}
add_action('init','create_collaborations');
function cw_post_type_collaborations()
{
$supports = array('title', 'editor', 'thumbnail', 'revisions');
$labels = array(
'name' => _x('Collaborations', 'plural'),
'singular_name' => _x('Collaborations', 'singular'),
'menu_name' => _x('Collaborations', 'admin menu'),
'name_admin_bar'=> _x('Collaborations', 'admin bar'),
'add_new' => _x('Add New', 'add new'),
'add_new_item' => __('Add New Collaborations'),
'new_item' => __('New Collaborations'),
'edit_item' => __('Edit Collaborations'),
'view_item' => __('View Collaborations'),
'all_items' => __('View Collaborations'),
'search_items' => __('Search Collaborations'),
'not_found' => __('No Collaborations found.')
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => true,
'query_var' => true,
'rewrite' => array('slug' => 'collaborations'),
'has_archive' => true,
'hierarchical' => false
);
register_post_type('collaborations', $args);
}
add_action('init', 'cw_post_type_collaborations');