我有一个里面有地图的课程。它使用连接表进行映射。我希望对象ID也是地图的关键,因此更容易找到它们。但是,当我尝试在Hibernate-3.6.6中定义它时,它会为DB中的键创建额外的列,或者如果我正在添加' inverseJoinColumns'则只会抱怨重复映射。有人知道如何解决这个问题吗?
@Entity
@Table(name = "Sources")
@Lazy(false)
public class Sources {
@ManyToMany( fetch = FetchType.EAGER )
@JoinTable( name = "sources_lists", joinColumns = @JoinColumn( name = "list_id" ) )
@MapKeyColumn( name = "source_id" )
public Map<Integer, Source> getSources() { return sources; }
public void setSources( Map<Integer, Source> sourcesList ) { this.adSources = adSourcesList; }
private Map<Integer, Source> sources;
@Override
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column( name="id", unique = true, nullable = false, updatable = false )
public Integer getId() { return super.getId(); }
}