-->
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: Use of @OneToMany or @ManyToMany targeting an unmapped class
PostPosted: Thu Dec 14, 2006 1:23 pm 
Beginner
Beginner

Joined: Sun Feb 20, 2005 12:14 am
Posts: 49
Hibernate version:
3.2.1 GA

I have two classes like such:

Code:
@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Category implements TanEntity, Imageable
{
...
    @Id
    private String id;
   
    @Version
    private Long version = null;
....
....
    @CollectionOfElements
    @OneToMany(cascade = CascadeType.ALL)
    @MapKey(name = "name")
    @JoinColumn
    @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    private Map<String, CategoryAttribute> attributeValues = new HashMap<String, CategoryAttribute>();
....
....
}


Code:
@Entity
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class CategoryAttribute implements TanEntity
{
  @Id
  @GeneratedValue(generator = "system-uuid")
  @GenericGenerator(name = "system-uuid", strategy = "uuid")
  private String id;
 
  @Version
  private Long version;
 
  private String name;

  @CollectionOfElements
  @org.hibernate.annotations.MapKey(columns={@Column(name="productCount")})
  @Column(name="productCount", nullable=false, columnDefinition="INTEGER UNSIGNED")
  private Map<String, Integer> values = new HashMap<String, Integer>();
 
   ....
   ....
}

Both classes are mapped in the hibernate.cfg.xml file like such:

Code:
....
....
  <mapping class="com.ac.tan.core.beans.CategoryAttribute"/>
  <mapping class="com.ac.tan.core.beans.Category"/>
....


When I deploy my web application, I see the following trace in my tomcat logs:

Code:
1534 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/t] listenerStart [3696] - Exception sending context initialized event to listener instance of class com.ac.tan.web.TanContextListener
org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.ac.tan.core.beans.Category.attributeValues[com.ac.tan.core.beans.CategoryAttribute]
        at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1016)
        at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:567)
        at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:80)
        at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
        at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
        at com.ac.tan.core.TanContext.configHibernate(TanContext.java:403)
        at com.ac.tan.core.TanContext.startup(TanContext.java:209)
        at com.ac.tan.web.TanWebApplication.startup(TanWebApplication.java:134)
        at com.ac.tan.web.TanContextListener.contextInitialized(TanContextListener.java:23)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Any pointers?


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.