Hi,
I created two different classes with OneToMany relationship but while executing this code I am getting one error like
... 63 more Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: QuoteSync.quoteSyncLineItemsSet[QuoteSyncLineItems] at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1071) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1177) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1162) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 70 more
Please help me on this. Where I made mistake
import java.io.Serializable; import java.sql.Date; import java.util.Set;
import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator; import javax.persistence.Table; import com.cat.solar.wp.action.common.CommonConstants;
@Entity @Table(name="WP_QUOTE_SYNC_STATUS",schema=CommonConstants.SCHEMA_NAME) public class QuoteSync implements Serializable {
/** TODO Update comment for serialVersionUID. */ private static final long serialVersionUID = -4520020666687496320L;
private Integer id = null; private Set<QuoteSyncLineItems> quoteSyncLineItemsSet=null;
@Id @SequenceGenerator(name="idGenerator",sequenceName=CommonConstants.SCHEMA_NAME+".WP_QUOTE_SYNC_STATUS_SEQ") @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="idGenerator") @Column(name="ID") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; }
@OneToMany(mappedBy="quoteSync") public Set<QuoteSyncLineItems> getQuoteSyncLineItemsSet() { return quoteSyncLineItemsSet; } public void setQuoteSyncLineItemsList( Set<QuoteSyncLineItems> quoteSyncLineItemsSet) { this.quoteSyncLineItemsSet = quoteSyncLineItemsSet; }
} }
-------------------------------------------------
import javax.persistence.Column; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.SequenceGenerator; import javax.persistence.Table;
import org.hibernate.annotations.Entity;
@Entity @Table(name="WP_QUOTE_SYNC_STATUS_LINE", schema=CommonConstants.SCHEMA_NAME) public class QuoteSyncLineItems {
private Integer syncStatusLineId = null; private QuoteSync quoteSync = null; @Id @SequenceGenerator(name="idGen", schema=CommonConstants.SCHEMA_NAME+".WP_QUOTE_SYNC_STATUS_LINE_SEQ") @GeneratedValue(generator="idGen",strategy=GenerationType.SEQUENCE) @Column(name="ID") public Integer getSyncStatusLineId() { return syncStatusLineId; } public void setSyncStatusLineId(Integer syncStatusLineId) { this.syncStatusLineId = syncStatusLineId; }
@ManyToOne @JoinColumn(name ="WP_QUOTE_SYNC_STATUS_ID") public QuoteSync getQuoteSync() { return quoteSync; } public void setQuoteSync(QuoteSync quoteSync) { this.quoteSync = quoteSync; }
}
|