Hi, with spring 3.0.6, hibernate 4 and cxf, I 've written the following code in webservice to invoke a remote(obj) operation. But it doesn't invoke the sql delete query.
here is my web serivce client code in a service facade class:
I tried to test the remove function in SoapUI, it also doesn't invoke the delete sql query at all.Code:@Override public void remove(String productId, String[] categoryIds) { if (categoryIds.length > 0) { Collection<ProductCategoryAssociate> pList = this.findByProductId(Integer.valueOf(productId), 0, this.count()); Iterator<ProductCategoryAssociate> iterator = pList.iterator(); for (int i=0; i<categoryIds.length; i++) { while (iterator.hasNext()) { ProductCategoryAssociate p = iterator.next(); if (p.getCategoryId().getCategoryId().compareTo(Integer.valueOf(categoryIds[i])) == 0) { logger.debug("==== removing product+category:"+p.toString()); this.remove(p); } } } } }
What might be the issue in my project?
Here is my backend entity class:
Any suggestion is very much appreciated.Code:@Entity @Table(name = "product_category_associate", catalog = "houseware", schema = "") @XmlRootElement @NamedQueries({ @NamedQuery(name = "ProductCategoryAssociate.findAll", query = "SELECT p FROM ProductCategoryAssociate p"), @NamedQuery(name = "ProductCategoryAssociate.findByAssociateId", query = "SELECT p FROM ProductCategoryAssociate p WHERE p.associateId = :associateId"), @NamedQuery(name = "ProductCategoryAssociate.findByTotalItems", query = "SELECT p FROM ProductCategoryAssociate p WHERE p.totalItems = :totalItems"), @NamedQuery(name = "ProductCategoryAssociate.findByCategoryId", query = "SELECT p FROM ProductCategoryAssociate p WHERE p.categoryId.categoryId = :catgoryId"), @NamedQuery(name = "ProductCategoryAssociate.findByProductId", query = "SELECT p FROM ProductCategoryAssociate p WHERE p.productId.productId = :productId") }) public class ProductCategoryAssociate implements Serializable { private static final long serialVersionUID = 1L; @Id @Basic(optional = false) @NotNull @Column(name = "associate_id") private Integer associateId; @Column(name = "total_items") private Integer totalItems; @JoinColumn(name = "category_id", referencedColumnName = "category_id") @ManyToOne(optional = false) private CategorySubcategories categoryId; @JoinColumn(name = "product_id", referencedColumnName = "product_id") @ManyToOne(optional = false) private Product productId; public ProductCategoryAssociate() { } public ProductCategoryAssociate(Integer associateId) { this.associateId = associateId; } public Integer getAssociateId() { return associateId; } public void setAssociateId(Integer associateId) { this.associateId = associateId; } public Integer getTotalItems() { return totalItems; } public void setTotalItems(Integer totalItems) { this.totalItems = totalItems; } public CategorySubcategories getCategoryId() { return categoryId; } public void setCategoryId(CategorySubcategories categoryId) { this.categoryId = categoryId; } public Product getProductId() { return productId; } public void setProductId(Product productId) { this.productId = productId; } @Override public int hashCode() { int hash = 0; hash += (associateId != null ? associateId.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 ProductCategoryAssociate)) { return false; } ProductCategoryAssociate other = (ProductCategoryAssociate) object; if ((this.associateId == null && other.associateId != null) || (this.associateId != null && !this.associateId.equals(other.associateId))) { return false; } return true; } @Override public String toString() { return "Product.entity.ProductCategoryAssociate[ associateId=" + associateId + " ]"; } }
Thanks
Sam


Reply With Quote