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: org.hibernate.MappingException: Could not determine type for
PostPosted: Tue Feb 09, 2010 6:00 pm 
Newbie

Joined: Tue Sep 01, 2009 11:15 am
Posts: 4
I've seen this exception in other topics on the forum, but what I'm doing is a good deal simpler. I have two classes in a many-to-one relationship: A Host has collection of HostVals, each of which has a hostId property containing the primary key for the Host. Pretty simple.

The first line of the exception is:
org.hibernate.MappingException: Could not determine type for: java.util.List, for columns: [org.hibernate.mapping.Column(hostVals)]

Is it saying it can't figure that it's a List of HostVal objects?

Here are the two classes:
Code:
@Entity

public class Host implements Serializable {

   private static final long serialVersionUID = 1L;

   @Id
   @Column(name="hostId", length=40)
   private String hostId;
   private List<HostVal> hostVals;

   public Host() {
      super();
   }   

   public String getHostId() {
      return this.hostId;
   }

   public void setHostId(String hostId) {
      this.hostId = hostId;
   }

   @OneToMany(mappedBy="hostId")
   public List<HostVal> getHostVals() {
      return hostVals;
   }

   public void setHostVals(List<HostVal> hostVals) {
      this.hostVals = hostVals;
   }
   
}


Code:
@Entity

public class HostVal implements Serializable {
   
   private static final long serialVersionUID = 1L;

   @Id   
   @GeneratedValue
   private long hostValId;
   @Column(name="hostId", length=40)
   private String hostId;
   @Column(length=30)
   private String keyName;
   @Column(length=80)
   private String keyValue;
   private Host host;
   
   public HostVal() {
      super();
   }

   public long getHostValId() {
      return hostValId;
   }

   public void setHostValId(long hostValId) {
      this.hostValId = hostValId;
   }

   @ManyToOne(optional = true)
   public String getHostId() {
      return hostId;
   }

   public void setHostId(String hostId) {
      this.hostId = hostId;
   }

   public String getKeyName() {
      return keyName;
   }

   public void setKeyName(String keyName) {
      this.keyName = keyName;
   }

   public String getKeyValue() {
      return keyValue;
   }

   public void setKeyValue(String keyValue) {
      this.keyValue = keyValue;
   }

   public Host getHost() {
      return host;
   }

   public void setHost(Host host) {
      this.host = host;
   }
   
}


Top
 Profile  
 
 Post subject: Re: org.hibernate.MappingException: Could not determine type for
PostPosted: Tue Feb 09, 2010 6:21 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The many-to-one you have mapped on HostVal.getHostId() should be on getHost(). Get rid of the HostVal.hostId field and the getter and setter for it. Change the mappedBy="hostId" that you have in the Host.getHostVals() method to mappedBy="host". This should get you a bit further. Read about many-to-one and collection annotations in the documentation for more information: http://docs.jboss.org/hibernate/stable/ ... ml#d0e1177


Top
 Profile  
 
 Post subject: Re: org.hibernate.MappingException: Could not determine type for
PostPosted: Wed Feb 10, 2010 9:44 am 
Newbie

Joined: Tue Sep 01, 2009 11:15 am
Posts: 4
I read the link you posted previously, but missed what you pointed out. Thanks.

Made the changes, but it's still failing the same way. The context for all this is an Eclipse JPA project using Tomcat 6/JSE 1.6 (not JEE). When the relational annotations are removed, things work without any problems.


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.