7
我有一個關係,使用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;
這種事情很好地工作在多對一像這樣:
@ManyToOne
@JoinColumn(name = "service_call_id", referencedColumnName = "id")
@ForeignKey(name = "job_service_call_fk")
@Index(name = "job_service_call_fk")
private ServiceCall serviceCall;
我想,以確保外國key在PostgreSQL上獲得索引,並且該模式在MySQL上看起來類似,因此具有相同名稱的@ForeignKey和@Index(MySQL始終創建一個與FK具有相同名稱的索引)。
我無法在反面創建索引,因爲FileSystemLocation不知道關係。因此JoinTable。
org.hibernate.MappingException: Unable to find logical column name from physical name null in table jobs
有誰知道如何創建使用Hibernate JoinTable外鍵索引:因爲Hibernate在工作發現沒有列索引
前者例如失敗了呢?
不是我想要的,但我想這是我想聽到的聲音。 – 2010-12-22 13:57:01