解决方案 »
- 把jsp页面的内容生成为pdf
- 从数据库中读出一组数据在jsp页面循环显示,和一组循环显示的删除按钮,如何点击其中一个按钮删除对应的数据
- Struts2+JPA+SPRING的问题
- myeclipse启动后出现句子,不明白什么意思
- 请问 那个 面包屑导航条 怎么实现呢?
- jstl标签的问题??
- 两个站点之间的数据库连接池是否会有影响?
- hibernate中,当通过SessionFactory.openSession返回一个session对象时,该session对象是不是不含用任何持久化对象?
- 有关JFreeChart的问题
- jsp中用out.println();来动态输出xml文件,为什么有时能显示,有时什么都没有呢?
- spring 自定义annotation
- 请问 ServletInputStream的 read(byte[], int, int)方法一次最多能读取多少字符?
检查下代码,看是否有类型转换错误,或者映射中有类型映射的错误
我当然知道是转换错误,我是想知道这个是什么原因导致的转换错误?这个转成PersistentCollection是什么东西?
以前也碰到过类似问题,但时间有点久远,脑袋又不好使,等大神来解决。
goods关联了product 是一对多的关系
我更改了goods里面的product的信息
controller类代码
this.goodsService.update(goods);serviceImpl类代码:
Goods good = (Goods)super.update(goods);
update调用的是下面DaoImpl来实现的DaoImpl代码是调用的:
this.session.merge(goods);merge的时候应该才报的这个问题
实体类
@Entity
@Table(name="goods")
public class Goods extends BaseEntity
{
private static final long serialVersionUID = -6977025562650112419L;
private Set<Product> products = new HashSet<Product>(); @OneToMany(mappedBy="goods", fetch=FetchType.EAGER, cascade={javax.persistence.CascadeType.ALL}, orphanRemoval=true)
public Set<Product> getProducts()
{
return this.products;
}@Entity
@Table(name="product")
public class Product extends BaseEntity{
private Goods good;
private List<ProductImage> productImages = new ArrayList();
private Set<Review> reviews = new HashSet();
private Set<Consultation> consultations = new HashSet();
private Set<Tag> tags = new HashSet();
private Set<Member> favoriteMembers = new HashSet();
private Set<Specification> specifications = new HashSet();
private Set<SpecificationValue> specificationValues = new HashSet();
private Set<Promotion> promotions = new HashSet();
private Set<CartItem> cartItems = new HashSet();
private Set<OrderItem> orderItems = new HashSet();
private Set<GiftItem> giftItems = new HashSet();
private Set<ProductNotify> productNotifies = new HashSet();
private Map<MemberRank, BigDecimal> memberPrice = new HashMap();
private Map<Parameter, String> parameterValue = new HashMap();
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(nullable=false, updatable=false)
public Goods getGoods()
{
return this.good;
} public void setGoods(Goods goods)
{
this.good = goods;
}
@Valid
@ElementCollection
@CollectionTable(name="product_product_image")
public List<ProductImage> getProductImages()
{
return this.productImages;
} public void setProductImages(List<ProductImage> productImages)
{
this.productImages = productImages;
} @OneToMany(mappedBy="product", fetch=FetchType.LAZY, cascade={javax.persistence.CascadeType.REMOVE})
public Set<Review> getReviews()
{
return this.reviews;
} public void setReviews(Set<Review> reviews)
{
this.reviews = reviews;
} @OneToMany(mappedBy="product", fetch=FetchType.LAZY, cascade={javax.persistence.CascadeType.REMOVE})
public Set<Consultation> getConsultations()
{
return this.consultations;
} public void setConsultations(Set<Consultation> consultations)
{
this.consultations = consultations;
} @ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="product_tag")
@OrderBy("order asc")
public Set<Tag> getTags()
{
return this.tags;
} public void setTags(Set<Tag> tags)
{
this.tags = tags;
} @ManyToMany(mappedBy="favoriteProducts", fetch=FetchType.LAZY)
public Set<Member> getFavoriteMembers()
{
return this.favoriteMembers;
} public void setFavoriteMembers(Set<Member> favoriteMembers)
{
this.favoriteMembers = favoriteMembers;
} @ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="product_specification")
@OrderBy("order asc")
public Set<Specification> getSpecifications()
{
return this.specifications;
} public void setSpecifications(Set<Specification> specifications)
{
this.specifications = specifications;
} @ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="product_specification_value")
@OrderBy("specification asc")
public Set<SpecificationValue> getSpecificationValues()
{
return this.specificationValues;
} public void setSpecificationValues(Set<SpecificationValue> specificationValues)
{
this.specificationValues = specificationValues;
} @ManyToMany(mappedBy="products", fetch=FetchType.LAZY)
public Set<Promotion> getPromotions()
{
return this.promotions;
} public void setPromotions(Set<Promotion> promotions)
{
this.promotions = promotions;
} @OneToMany(mappedBy="product", fetch=FetchType.LAZY, cascade={javax.persistence.CascadeType.REMOVE})
public Set<CartItem> getCartItems()
{
return this.cartItems;
} public void setCartItems(Set<CartItem> cartItems)
{
this.cartItems = cartItems;
} @OneToMany(mappedBy="product", fetch=FetchType.LAZY)
public Set<OrderItem> getOrderItems()
{
return this.orderItems;
} public void setOrderItems(Set<OrderItem> orderItems)
{
this.orderItems = orderItems;
} @OneToMany(mappedBy="gift", fetch=FetchType.LAZY, cascade={javax.persistence.CascadeType.ALL})
public Set<GiftItem> getGiftItems()
{
return this.giftItems;
} public void setGiftItems(Set<GiftItem> giftItems)
{
this.giftItems = giftItems;
} @OneToMany(mappedBy="product", fetch=FetchType.LAZY, cascade={javax.persistence.CascadeType.REMOVE})
public Set<ProductNotify> getProductNotifies()
{
return this.productNotifies;
} public void setProductNotifies(Set<ProductNotify> productNotifies)
{
this.productNotifies = productNotifies;
} @ElementCollection(fetch=FetchType.LAZY)
@CollectionTable(name="product_member_price")
public Map<MemberRank, BigDecimal> getMemberPrice()
{
return this.memberPrice;
} public void setMemberPrice(Map<MemberRank, BigDecimal> memberPrice)
{
this.memberPrice = memberPrice;
} @ElementCollection(fetch=FetchType.LAZY)
@CollectionTable(name="product_parameter_value")
public Map<Parameter, String> getParameterValue()
{
return this.parameterValue;
} public void setParameterValue(Map<Parameter, String> parameterValue)
{
this.parameterValue = parameterValue;
}
public void setProducts(Set<Product> products)
{
this.products = products;
}