Hi all,
I am using annotation, below is the error i am getting,
Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: com.data.items.dao.system.pojo.Menu.menuRoleAccess
This is my Menu POJO:
public class Menu implements java.io.Serializable {
/** * */ private static final long serialVersionUID = 1L; // Fields
private Integer serial; private String description; private Integer parent; private String action; private String label; private String status; private Date dateCreated; private Integer sequence; private String actionListerner; private String target; private Set<MenuRoleAccess> menuRoleAccesses = new HashSet(0); private MenuRoleAccess menuRoleAccess;
// Constructors
/** default constructor */ public Menu() { }
/** minimal constructor */ public Menu(Integer serial, Integer parent, String status, Integer sequence) { this.serial = serial; this.parent = parent; this.status = status; this.sequence = sequence; } /** full constructor */ public Menu(Integer serial, String description, Integer parent, String action, String label, String status, Date dateCreated, Integer sequence, String actionListerner, String target,Set menuRoleAccesses) { this.serial = serial; this.description = description; this.parent = parent; this.action = action; this.label = label; this.status = status; this.dateCreated = dateCreated; this.sequence = sequence; this.actionListerner = actionListerner; this.target = target; this.menuRoleAccesses = menuRoleAccesses; }
// Property accessors @Id @GeneratedValue(strategy=GenerationType.TABLE) @Column(name="SERIAL") public Integer getSerial() { return this.serial; } public void setSerial(Integer serial) { this.serial = serial; } @Column(name="DESCRIPTION", nullable=true) public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } @Column(name="PARENT", nullable=false) public Integer getParent() { return this.parent; } public void setParent(Integer parent) { this.parent = parent; } @Column(name="ACTION", nullable=true) public String getAction() { return this.action; } public void setAction(String action) { this.action = action; } @Column(name="LABEL", nullable=true) public String getLabel() { return this.label; } public void setLabel(String label) { this.label = label; } @Column(name="STATUS", nullable=false) public String getStatus() { return this.status; } public void setStatus(String status) { this.status = status; } @Column(name="DATE_CREATED", nullable=true) public Date getDateCreated() { return this.dateCreated; } public void setDateCreated(Date dateCreated) { this.dateCreated = dateCreated; } @Column(name="SEQUENCE", nullable=false) public Integer getSequence() { return this.sequence; } public void setSequence(Integer sequence) { this.sequence = sequence; } @Column(name="ACTION_LISTERNER", nullable=false) public String getActionListerner() { return this.actionListerner; } public void setActionListerner(String actionListerner) { this.actionListerner = actionListerner; } @Column(name="TARGET", nullable=false) public String getTarget() { return this.target; } public void setTarget(String target) { this.target = target; } @OneToMany(cascade = {CascadeType.ALL},fetch = FetchType.EAGER, mappedBy="Menu") public Set getMenuRoleAccesses() { return this.menuRoleAccesses; }
public void setMenuRoleAccesses(Set menuRoleAccesses) { this.menuRoleAccesses = menuRoleAccesses; } @OneToMany(cascade = {CascadeType.ALL},fetch = FetchType.EAGER, mappedBy="Menu") public MenuRoleAccess getMenuRoleAccess(){ //log.debug("getLogin..."+menuRoleAccesses.size()); Iterator<MenuRoleAccess> it = menuRoleAccesses.iterator(); while (it.hasNext()) { menuRoleAccess = (MenuRoleAccess) it.next(); } return menuRoleAccess; }
This is my MenuRoleAccess POJO:
public class MenuRoleAccess implements java.io.Serializable {
/** * */ private static final long serialVersionUID = 1L; // Fields
private int serial; private Menu menu; private UserRole userRole; private int status;
// Constructors
/** default constructor */ public MenuRoleAccess() { }
/** full constructor */ public MenuRoleAccess(int serial, Menu menu, UserRole userRole, int status) { this.serial = serial; this.menu = menu; this.userRole = userRole; this.status = status; }
// Property accessors @Id @GeneratedValue(strategy=GenerationType.TABLE) @Column(name="SERIAL") public int getSerial() { return this.serial; } public void setSerial(int serial) { this.serial = serial; } @ManyToOne @JoinColumn(name="SERIAL", nullable=false) public Menu getMenu() { return this.menu; } public void setMenu(Menu menu) { this.menu = menu; } @ManyToOne @JoinColumn(name="USER_ROLE_ID",nullable = false,updatable = false,insertable = false) public UserRole getUserRole() { return this.userRole; } public void setUserRole(UserRole userRole) { this.userRole = userRole; } @Column(name="STATUS", nullable=true) public int getStatus() { return this.status; } public void setStatus(int status) { this.status = status; } }
My question is how to create the relationship of one to many here. One Menu have different menuroleaccess.How to specifiy the relation apart from Collection in Annotations???Thank you.
|