hibernatemany-to-manyxdoclet

hibernate manytomany xdoclet


is this the right way of using it? because it does not work. i have the same thing in the RoleDAO. the two tables for users and roles are generated, but the table that links userid to roleid is not.

(more info on the syntax bellow http://xdoclet.codehaus.org/HibernateTags#HibernateTags-hibernate.manytomany hibernate xdoclet tags)

/**
 * @hibernate.id generator-class="native"
 * @hibernate.generator-param name="sequence" value="seq_userid"
 * @hibernate.many-to-many column="roleID"
 *                         class="domain.company.product.service.cm.RoleDAO.java"
 */
public Integer getUserID() {
    return userID;
}

focus please on
many-to-many column="roleID" class="domain.company.product.service.cm.RoleDAO.java"

edit:

ok. now using:

private Set<RoleDAO> roles = new HashSet<RoleDAO>();

/**
 * @hibernate.many-to-many column="roleID"
 *                         class="domain.company.producut.service.cm.RoleDAO.java"
 */
public Set<RoleDAO> getRoles() {
    return roles;
}

but still not seing the table that links roles and users.


Solution

  • here is how i finally managed to do it.

    (from UserDAO)

    /**
     * @hibernate.bag table="user_roles" cascade="save-update" lazy="true"
     * @hibernate.collection-key column="roleID"
     * @hibernate.collection-many-to-many 
     *                                    class="domain.company.product.service.cm.RoleDAO"
     *                                    column="roleID"
     */
    public List<RoleDAO> getRoles() {
    return roles;
    }