-->
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: "Unbound type and no explicit target entity"-exception
PostPosted: Sun Aug 09, 2009 3:41 pm 
Newbie

Joined: Sun Aug 09, 2009 3:29 pm
Posts: 1
I believe I'm getting this exception even though I shouldn't be getting it? Or am I missing something?

Code:
Caused by: org.hibernate.AnnotationException: Property foo.Foo.bars has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type
        at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:993)
   at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:833)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:645)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
   at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
   at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:416)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
   at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:227)
   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:273)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)



These are the beans:

Code:
package foo;
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Foo<B extends Bar> implements Serializable {
  private static final long serialVersionUID = 1l;
  @Id
  private String id = UUID.randomUUID().toString();
  @OneToMany(targetEntity = Bar.class)
  private List<B> bars;
}

@Entity
public abstract class Bar implements Serializable {
  private static final long serialVersionUID = 1l;
  @Id
  private String id = UUID.randomUUID().toString();
}


Top
 Profile  
 
 Post subject: Re: "Unbound type and no explicit target entity"-exception
PostPosted: Tue May 04, 2010 8:56 am 
Newbie

Joined: Tue May 04, 2010 8:53 am
Posts: 2
I'm having the same issue and haven't found the solution yet. Did you ever solve this problem?


Top
 Profile  
 
 Post subject: Re: "Unbound type and no explicit target entity"-exception
PostPosted: Fri May 22, 2015 6:03 am 
Newbie

Joined: Fri May 22, 2015 5:57 am
Posts: 1
After lots of testing, trying to get Java parameterisation working with an abstract parent (Single-table inheritance), and an abstract child table (one-table-per-class inheritance), I've given up.

It may be possible in simple instances, but often you get problems where Hibernate tries to instantiate an abstract (parameterised) class as an entity, which is where your error appears.

I would suggest rewriting it using the JPA inheritance, moving the parameterised stuff down into extending classes. That way you get the same polymorphism back from the database.

In either case, make your abstract classes @MappedSuperclass, not @Entity, then hibernate won't try and create Entities for them.

Code:
    @MappedSuperclass
    @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
    @DiscriminatorColumn(name = "CLASS_TYPE", discriminatorType = DiscriminatorType.STRING)
    public abstract class ClassA {

      [...]

    }


extension B:
Code:
    @Entity
    @DiscriminatorValue=("B")
    public class ClassB extends ClassA {
      @OneToOne
      @JoinColumn(name = "mycolumn_id")
      private Integer instance;

      [...]
    }


extension C:
Code:
    @Entity
    @DiscriminatorValue=("C")
    public class ClassC extends ClassA {
      @OneToOne
      @JoinColumn(name = "mycolumn_id")
      private String instance;
      [...]
    }


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.