users@glassfish.java.net

Hello, Thank you for the

From: <forums_at_java.net>
Date: Mon, 28 Mar 2011 06:06:46 -0500 (CDT)

 

 

 Hello,

Thank you for the answer.

There is no Constructor like that in my CategorySubcategories class.

I just want to construct a sql with multi select clause:

SELECT node.category_name, (COUNT(parent.category_name) - 1) AS depth

                        FROM category_subcategories AS node,

                        category_subcategories AS parent

                        WHERE node.lft BETWEEN parent.lft AND
parent.rgt

                        AND node.category_name = 'PORTABLE
ELECTRONICS'

                        GROUP BY node.category_name

 

Here is my entity class:

@Entity

@Table(name = "category_subcategories", catalog = "houseware", schema = "")

@XmlRootElement

@NamedQueries({

    @NamedQuery(name = "CategorySubcategories.findAll", query = "SELECT c
FROM CategorySubcategories c"),

    @NamedQuery(name = "CategorySubcategories.findByCategoryId", query =
"SELECT c FROM CategorySubcategories c WHERE c.categoryId = :categoryId"),

    @NamedQuery(name = "CategorySubcategories.findByCategoryName", query =
"SELECT c FROM CategorySubcategories c WHERE c.categoryName =
:categoryName"),

    @NamedQuery(name = "CategorySubcategories.findByLft", query = "SELECT
c FROM CategorySubcategories c WHERE c.lft = :lft"),

    @NamedQuery(name = "CategorySubcategories.findByRgt", query = "SELECT
c FROM CategorySubcategories c WHERE c.rgt = :rgt")

})

public class CategorySubcategories implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id

    @Basic(optional = false)

    @NotNull

    @Column(name = "category_id", nullable = false)

    private Integer categoryId;

    @Size(max = 64)

    @Column(name = "category_name", length = 64)

    private String categoryName;

    @Column(name = "lft")

    private Integer lft;

    @Column(name = "rgt")

    private Integer rgt;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "categoryId")

    private Collection<Product> productCollection;

    @OneToMany(cascade = CascadeType.ALL, mappedBy =
"categorySubcategories")

    private Collection<ProductCategoryAssociate>
productCategoryAssociateCollection;

 

    public CategorySubcategories() {

    }

 

    public CategorySubcategories(Integer categoryId) {

        this.categoryId = categoryId;

    }

 

    public Integer getCategoryId() {

        return categoryId;

    }

 

    public void setCategoryId(Integer categoryId) {

        this.categoryId = categoryId;

    }

 

    public String getCategoryName() {

        return categoryName;

    }

 

    public void setCategoryName(String categoryName) {

        this.categoryName = categoryName;

    }

 

    public Integer getLft() {

        return lft;

    }

 

    public void setLft(Integer lft) {

        this.lft = lft;

    }

 

    public Integer getRgt() {

        return rgt;

    }

 

    public void setRgt(Integer rgt) {

        this.rgt = rgt;

    }

 

    @XmlTransient

    public Collection<Product> getProductCollection() {

        return productCollection;

    }

 

    public void setProductCollection(Collection<Product>
productCollection) {

        this.productCollection = productCollection;

    }

 

    @XmlTransient

    public Collection<ProductCategoryAssociate>
getProductCategoryAssociateCollection() {

        return productCategoryAssociateCollection;

    }

 

    public void
setProductCategoryAssociateCollection(Collection<ProductCategoryAssociate>
productCategoryAssociateCollection) {

        this.productCategoryAssociateCollection =
productCategoryAssociateCollection;

    }

 

    @Override

    public int hashCode() {

        int hash = 0;

        hash += (categoryId != null ? categoryId.hashCode() : 0);

        return hash;

    }

 

    @Override

    public boolean equals(Object object) {

        // TODO: Warning - this method won't work in the case the id
fields are not set

        if (!(object instanceof CategorySubcategories)) {

            return false;

        }

        CategorySubcategories other = (CategorySubcategories) object;

        if ((this.categoryId == null && other.categoryId != null) ||
(this.categoryId != null && !this.categoryId.equals(other.categoryId))) {

            return false;

        }

        return true;

    }

 

    @Override

    public String toString() {

        return
"au.com.houseware.server.ejb.entity.CategorySubcategories[ categoryId=" +
categoryId + " ]";

    }

 

}

Thanks a lot

Sam


--
[Message sent by forum member 'samsam8899']
View Post: http://forums.java.net/node/785795