-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Duplicate property mapping _*Backref
PostPosted: Sun Oct 11, 2009 2:32 am 
Newbie

Joined: Tue Nov 22, 2005 12:47 am
Posts: 6
I have a structure which contains two classes.... each defining a @OneToMany association to a common class (SaleItem).
The following association is shown below:

Sale -----< SaleItem >------- ItemDescription

class SaleItem contains this association:
Code:
   @ManyToOne
   @JoinColumn(name="description_id", insertable=false, updatable=false, nullable=false)
   public ItemDescription getDescription() {
      return description;
   }
   
   @ManyToOne
   @JoinColumn(name="sale_id", insertable=false, updatable=false, nullable=false)
   public Sale getSale() {
      return sale;
   }


for class Sale:
Code:
   @OneToMany(cascade=CascadeType.ALL)
   @JoinColumn(name="sale_id", nullable=false)
   @org.hibernate.annotations.IndexColumn(name="sposition")
   @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
   public List<SaleItem> getSaleItems() {
      return saleItems;
   }


for class ItemDescription:
Code:
   @OneToMany(cascade=CascadeType.ALL)
   @JoinColumn(name="description_id", nullable=false)
   @org.hibernate.annotations.IndexColumn(name="idposition")
   @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
   public List<SaleItem> getSaleItems() {
      return saleItems;
   }


When I tried to execute my application, it throws up the error:
Code:
Caused by: org.hibernate.MappingException: Duplicate property mapping of _saleItemsBackref found in com.ifvi.rims.entities.SaleItem
   at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:459)
   at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:449)
   at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:1121)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1306)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
   ... 37 more


Im stuck with this problem. Please help me to solve this problem!. Thank you very much!


Top
 Profile  
 
 Post subject: Re: Duplicate property mapping _*Backref
PostPosted: Sun Oct 11, 2009 11:02 pm 
Newbie

Joined: Tue Nov 22, 2005 12:47 am
Posts: 6
any ideas?...


Top
 Profile  
 
 Post subject: Re: Duplicate property mapping _*Backref
PostPosted: Mon Oct 12, 2009 1:13 am 
Newbie

Joined: Fri Oct 09, 2009 5:01 am
Posts: 2
HI

I Think you have not mentioned when did you get this problem.

You can try this , i dont know whether it will work.

for class Sale:
@OneToMany(mappedBy = "m_sale")

and for class ItemDescription:
@OneToMany(mappedBy = "m_ description")


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.