-->
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: org.hibernate.MappingException in annotated class: but why?
PostPosted: Fri May 12, 2006 10:09 pm 
Newbie

Joined: Fri May 12, 2006 9:54 pm
Posts: 1
I have an entity which references another using a join table. However, when I try running I get a

Code:
MappingException: Could not determine type for: com.test.Role, for columns: [org.hibernate.mapping.Column(elt)]


What puzzles me is that it already knows the fully qualified classname for the com.test.Role type; and given the Role class is in the classpath, what else does it need to know?

code exerpts (for the sake of brevity):

Role entity:
Code:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "role")
public class Role implements GrantedAuthority {
    private Integer id;
    private String vName;
   
     public Role() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
   
    @Column(name = "V_NAME", nullable = false)
    public String getVName() {
        return vName;
    }

    public void setVName(String vName) {
        this.vName = vName;
    }
   
}



User entity (which refers to the role):
Code:
import java.util.List;
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.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity @Table(name = "user") public class User{
   
    private Integer id;
    private String vName;
    private String password;
    private java.util.Collection <org.unintelligible.venue.business.om.Role> role;

    public User() {
    }
   
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", nullable = false)
    public Integer getId() {
        return this.id;
    }
   
    public void setId(Integer id) {
        this.id = id;
    }
   
    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(
            name="user_role",
            joinColumns = { @JoinColumn( name="user_id") },
            inverseJoinColumns = @JoinColumn( name="role_id")
    )
    public java.util.Collection<org.unintelligible.venue.business.om.Role> getRole() {
        return role;
    }
   
    public void setRole(java.util.Collection<org.unintelligible.venue.business.om.Role> role) {
        this.role = role;
    }
   
    @Column(name = "V_NAME", nullable = false)
    public String getVName() {
        return vName;
    }
   
    public void setVName(String vName) {
        this.vName = vName;
    }
   
    @Column(name = "PASSWORD", nullable = false)
    public String getPassword() {
        return password;
    }
   
    public void setPassword(String password) {
        this.password = password;
    } 
}


I am using Hibernate 3.0 CR1 (CR2 doesn't work for me), Annotations 3.1beta9, EntityManager 3.1.0beta8

I must be missing something obvious - I'm not having a problem with any of my other classes which use exactly the same type of mapping. Any help appreciated.

thanks,
Nick


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.