-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: List index behaviour
PostPosted: Mon Jul 12, 2010 7:12 am 
Newbie

Joined: Mon Jul 12, 2010 7:06 am
Posts: 6
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....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.