Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.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
Java 如何使用Hibernate注释在联接表上创建索引?_Java_Hibernate - Fatal编程技术网

Java 如何使用Hibernate注释在联接表上创建索引?

Java 如何使用Hibernate注释在联接表上创建索引?,java,hibernate,Java,Hibernate,我使用Hibernate注释建立了如下关系,这是我尝试的: public class Job{ ... @OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "jobs_resource_locations") @ForeignKey(name = "job_inputs_fk") @Index(name="job_inputs_fk") private List<FileSystemLocation> inputs;

我使用Hibernate注释建立了如下关系,这是我尝试的:

public class Job{

...

@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "jobs_resource_locations")
@ForeignKey(name = "job_inputs_fk")
@Index(name="job_inputs_fk")
private List<FileSystemLocation> inputs;
我想确保外键在PostgreSQL上被索引,并且模式在MySQL上看起来相似,因此@ForeignKey和@Index具有相同的名称(MySQL总是创建一个与FK同名的索引)

我无法在反向创建索引,因为FileSystemLocation不知道这种关系。因此是可接合的

前一个示例失败,因为Hibernate在作业中找不到要索引的列:

org.hibernate.MappingException: Unable to find logical column name from physical name null in table jobs

有人知道如何使用Hibernate在可连接外键上创建索引吗?

这并不是您希望得到的答案,但这是预期的行为。换句话说:这是不受支持的。有关更多详细信息,请参阅以下JIRA:


这不是我想要的,但我想这是我需要听到的。
org.hibernate.MappingException: Unable to find logical column name from physical name null in table jobs