Hi,
I have one easy problem, but I find a way how to solve it...
I have two entities... Category and ArticleCategory, Category has a list of ArticleCategories
Code:
@Entity
public class Category extends AbstractBusinessObject {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Name of the category
*/
@Column
private String name;
/**
* Subcategories
*/
@OneToMany(cascade=CascadeType.ALL)
@OrderColumn(name="order_categories")
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<Category> subCategories;
@OneToMany(mappedBy="category", cascade=CascadeType.ALL)
//============== IMPORTANT SECTION
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@IndexColumn(name="order_articles", nullable=false)
private List<ArticleCategory> articleCategories;
//==============
@ManyToOne
private Template template;
.
.
.
Code:
public class ArticleCategory extends AbstractBusinessObject{
@ManyToOne(fetch=FetchType.EAGER)
private Category category;
@ManyToOne(fetch=FetchType.EAGER)
.
.
.
The problem is, when I do
Code:
Category cat = categoryDAO.getById(((Category)parent).getId());
ArticleCategory ac = new ArticleCategory();
ac.setArticle(a);
ac.setCategory((Category)parent);
// articleCategoryDAO.save(ac);
cat.getArticleCategories().add(0, ac);
the index column is not set by hibernate (it is null) and the database throws an exception...i have tried almost everything, bud the result is still the save....
thanks for you advice....