我有一个productJob
表和一个quadrat
表。每个quadrat都可以安装在很多productJob
上,每productJob
个quadrats
可以有相同或不同种类的1到4 JoinTable telai_quadrati
!我有兴趣在产品作业上保持quadrat安装的顺序。例如第一,第二,第三或第四名!但是以下映射不会在@Entity
@Table(name = "telai")
public class ProductJob implements IProductJob, IProductJobProcessing{
@Embedded private QuadratGroup quadrateGroup = new QuadratGroup();
}
@Embeddable
public class QuadratGroup implements Serializable{
@OneToMany(targetEntity = Quadrat.class, cascade = CascadeType.ALL)
@JoinTable(
name = "telai_quadrati",
joinColumns = {@JoinColumn(name = "dbId", table = "telai")},
inverseJoinColumns = {@JoinColumn(name = "id", table = "quadrati")})
//@OrderColumn(name = "order")
@IndexColumn(name = "order")
public List<Quadrat> getQuadratList(){ //return an ordered list of the quadrats with at most 4 elements}
上创建订单列。我的映射有什么问题?无论如何都不会创建orderColumn!
@Entity
@Table(name = "quadrati")
public class Quadrat implements IQuadrat, Cloneable, Serializable{
@ManyToMany
@JoinTable(
name = "telai_quadrati",
joinColumns = @JoinColumn(name = "id", table = "quadrati"),
inverseJoinColumns = @JoinColumn(name = "dbId", table = "telai"))
private Set<ProductJob> productJobs;
很明显,对于quadrats,没有订单,所以我使用set!
{{1}}
答案 0 :(得分:1)
如果我使用属性访问,尽管方法访问,它仍然有效!像这样:
@OneToMany(targetEntity = Quadrat.class, cascade = CascadeType.ALL)
//@MapKeyJoinColumn(name="indice" , table = "telai_quadrati")
@JoinTable(
name = "telai_quadrati",
joinColumns = {@JoinColumn(name = "telaio_id", table = "telai")},
inverseJoinColumns = {@JoinColumn(name = "quadrato_id", table = "quadrati")})
@OrderColumn(name = "indice")
private List<Quadrat> quadratList;
但是我想知道为什么它不能用于方法访问,这会迫使我在我的项目中使用重型重构器! :(