-->
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.  [ 1 post ] 
Author Message
 Post subject: @OneToOne or @ManyToOne on X ref an unknown entity.. SOLVED
PostPosted: Tue Mar 09, 2010 4:19 pm 
Newbie

Joined: Tue Mar 09, 2010 4:11 pm
Posts: 1
hello dear community!

with my first post here, I'd like to outline a problem I'm trying to solve. I'm a hibernate beginner, so please tutor me a bit if I'm totally out :)

Error is:
Code:
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.my.model.entity.ItemPriceHistorySell.item references an unknown entity: com.my.model.entity.Item
   at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:103)
   at org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:502)
   at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:484)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:334)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1359)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:858)


let's have a look at the ItemPriceHistorySell class:
Code:
package com.my.model.entity;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

@Entity
public class ItemPriceHistorySell extends ItemPriceHistory {

   @ManyToOne
   private Customer customer;

// accessors
}


and at the referenced Item class:
Code:
package com.my.model.entity;

import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class Item extends PersistentEntity {
   private boolean enabled;
   private String name;
   private boolean is_catalog_item;

   public Item() {

   }
// accessors

}


I guess the problem lies in a fact, that this is an abstract class and thus is not "bound" by hibernate at it's startup directly. What should I do?

this is an example of how I subclass this Item:
Code:
package com.my.model.entity;

import java.util.List;

import javax.persistence.Entity;

@Entity
public class ItemSet extends Item {

   @OneToMany
   private List<Item> items;

   public ItemSet() {
   }

// accessors

}


edit: well, my first time here and a useless post... I forget to put the right @OneToMany mapping at the other side of this relation... sorry


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

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.