在hibernate中,当使用xml映射多对多时,它使用多对多这样:
<class name="com.lavin.test.app.dao.hibernate.association.many2many.model.Category2" table="category2" catalog="tt">
<set name="stocks" table="stock_category" inverse="true" lazy="true" fetch="select">
<key>
<column name="CATEGORY_ID" not-null="true" />
</key>
<many-to-many entity-name="com.lavin.test.app.dao.hibernate.association.many2many.model.Stock2">
<column name="STOCK_ID" not-null="true" />
</many-to-many>
</set>
</class>
但是,当使用注释时,它正在使用@ManyToOne:
@Embeddable
public class StockCategoryId3 implements java.io.Serializable {
private Stock3 stock;
private Category3 category;
@ManyToOne
public Stock3 getStock() {
return stock;
}
public void setStock(Stock3 stock) {
this.stock = stock;
}
@ManyToOne
public Category3 getCategory() {
return category;
}
public void setCategory(Category3 category) {
this.category = category;
}
}
在映射多对多关系时使用xml和注释之间不应该相同吗?为什么这两个不同?