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