Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dictionary JPQL查询更新CollectionTable_Dictionary_Jpa_Entity_Jpql - Fatal编程技术网

Dictionary JPQL查询更新CollectionTable

Dictionary JPQL查询更新CollectionTable,dictionary,jpa,entity,jpql,Dictionary,Jpa,Entity,Jpql,我拥有以下实体: @Entity(name = "Directory") @Table(name = "Directory") public Directory { @Id @Column(name = "id") protected String id; @ElementCollection @MapKeyColumn(name = "file") @CollectionTable(name = "Directory_Files", joinColumns = @JoinColumn(na

我拥有以下实体:

@Entity(name = "Directory")
@Table(name = "Directory")
public Directory {

@Id
@Column(name = "id")
protected String id;

@ElementCollection
@MapKeyColumn(name = "file")
@CollectionTable(name = "Directory_Files", joinColumns = @JoinColumn(name = "id"))
@Column(name = "hash")
protected Map<File, String> fileToHash;

...

}
有人在这个查询中发现了错误吗

非常感谢您的帮助。

“目录\u文件”是一个数据库表,不存在于您的对象模型中,因此无法在JPQ中使用-您需要访问目录中的fileToHash映射

不幸的是,JPQL批量更新语句将更新项定义为: 更新项目::=[标识变量]{单值可嵌入对象字段。}* {state_field |单值_object_field}=新的_值

fileToHash是一个集合,因此不能在Update语句中使用


您需要使用SQL查询并将其传递给EntityManager.createNativeQuery(sqlString)

是否有其他方法通过JPQL访问映射?我代码中的所有其他查询都基于JPQL,我希望保持一致。
UPDATE Directory t SET t.Directory_Files.hash = :hash WHERE t.Directory_Files.id = :id AND t.Directory_Files.file = :file