views:

40

answers:

0

hi guys, I just realized that seam-gen creates wrong entities for one to many relationships by default. First it uses HashSet instead of List, how can I change that?

This is my schema:
category(category_id, category_description, workgroup_id)
subcategory(subcategory_id, subcategory_description, category_id)

This is what should be created


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer categoryId;
    @Column(name = "category_description")
    private String categoryDescription;
    @Column(name = "workgroup_id")
    private int workgroupId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
    private List subcategoryList;

Instead this is what it creates:


 private Integer categoryId;
 private String categoryDescription;
 private int workgroupId;
 private Set subcategories = new HashSet(0);
 private Set subcategories_1 = new HashSet(0);
 private Set subcategories_2 = new HashSet(0);

Note above, there are 3 subcategories Set because I had populated 3 categories and their subcategories. So, if I had populated 100 categories, it would create 100 sets which is dumb.
How do I fix this?

Thanks