解决方案 »

  1.   

    帮up一下,楼主可以把对应的POJOjava代码贴出来看看
      

  2.   

    PRoleMenuId 代码如下:public class PRoleMenuId implements java.io.Serializable { // Fields private PMenu Pmenu;
    private PRole Prole; // Constructors /** default constructor */
    public PRoleMenuId() {
    } /** full constructor */
    public PRoleMenuId(PMenu Pmenu, PRole Prole) {
    this.Pmenu = Pmenu;
    this.Prole = Prole;
    } // Property accessors public PMenu getPMenu() {
    return this.Pmenu;
    } public void setPMenu(PMenu Pmenu) {
    this.Pmenu = Pmenu;
    } public PRole getPRole() {
    return this.Prole;
    } public void setPRole(PRole PRole) {
    this.Prole = Prole;
    } public boolean equals(Object other) {
    if ((this == other))
    return true;
    if ((other == null))
    return false;
    if (!(other instanceof PRoleMenuId))
    return false;
    PRoleMenuId castOther = (PRoleMenuId) other; return ((this.getPMenu() == castOther.getPMenu()) || (this.getPMenu() != null
    && castOther.getPMenu() != null && this.getPMenu().equals(
    castOther.getPMenu())))
    && ((this.getPRole() == castOther.getPRole()) || (this
    .getPRole() != null
    && castOther.getPRole() != null && this.getPRole()
    .equals(castOther.getPRole())));
    } public int hashCode() {
    int result = 17; result = 37 * result
    + (getPMenu() == null ? 0 : this.getPMenu().hashCode());
    result = 37 * result
    + (getPRole() == null ? 0 : this.getPRole().hashCode());
    return result;
    }}
    PRoleMenu 代码如下:
    public class PRoleMenu implements java.io.Serializable { // Fields private PRoleMenuId id; // Constructors /** default constructor */
    public PRoleMenu() {
    } /** full constructor */
    public PRoleMenu(PRoleMenuId id) {
    this.id = id;
    } // Property accessors public PRoleMenuId getId() {
    return this.id;
    } public void setId(PRoleMenuId id) {
    this.id = id;
    }}同时感谢楼上的各位朋友..TO: 一楼的朋友,你的过淲器很好,我看了一下.但是最终写的还是 hql语句......还是无法解决这个问题.
      

  3.   

    我不是很理解的需求,但是我可以给个建议,看行不行:
    对于多表查询一般建议还是用关联查询比较的好,无论从效率还是速度上来说都有一定的优势,http://adoze.bokee.com/viewdiary.25283769.html,你可以到这里看看,也许对你有帮助的,里面介绍了很多关于hibernate的查询方式
      

  4.   

    问题解决了...呵呵,,一个很简单的方法...说出来有一些丢人了..                        queryString.append("select m.menuId,m.menuName,"); 
    queryString.append("m.descn,m.tip,m.leaf,m.sortNum, ");
    queryString.append("m.menuType,m.forward,m.target,m.image ");
    queryString.append("from PMenu as m,PRoleMenu as mr,");
    queryString.append("PUser as su,PUserRole as sur ");
    queryString.append("where su.userId = sur.id.PUser ");
    queryString.append("and sur.id.PRole = mr.id.PRole ");
    queryString.append("and mr.id.PMenu = m.menuId ");
    queryString.append("and su.userId = " + userId );
    queryString.append("and m.PMenu = " + perId);
    mr.id.PMenu 中的PMenu为当前的映射名...换成他就可以了...