相关疑难解决方法(0)

1406
推荐指数
11
解决办法
67万
查看次数

org.hibernate.MappingException:无法确定:java.util.List的类型,在表:College,对于列:[org.hibernate.mapping.Column(students)]

现在,我正在学习hibernate,并开始在我的项目中使用它.这是一个CRUD应用程序.我使用hibernate进行所有的crud操作.它适用于所有人.但是,One-To-Many和Many-To-One,我厌倦了尝试它.最后它给了我以下错误.

org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)]

然后我再次浏览了这个视频教程.一开始对我来说非常简单.但是,我不能让它发挥作用.现在,它说

org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)]

我在互联网上运行了一些搜索,有人告诉它在Hibernate中一个错误,有些人说,通过添加@GenereatedValue,这个错误将被清除.但是,nothings对我有用,

我希望我能得到一些解决方案!

谢谢!

在这里我的代码:

College.java

@Entity
public class College {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int collegeId;
private String collegeName;


private List<Student> students;

@OneToMany(targetEntity=Student.class, mappedBy="college", fetch=FetchType.EAGER)
public List<Student> getStudents() {
    return students;
}
public void setStudents(List<Student> students) {
    this.students = students;
}//Other gettters & setters omitted …
Run Code Online (Sandbox Code Playgroud)

java orm hibernate

82
推荐指数
5
解决办法
18万
查看次数

@ElementCollection:错误无法确定类型:java.util.Set,用于列

这是我的Entity类

    @Entity // Model Class as a DB entity
    public class UserDetails 
    {
        @Id 
        private int userId;
        private String name;

        @ElementCollection
        private Set<Address> listOfAddresses = new HashSet();

           // Setters and Getters Below

    }
Run Code Online (Sandbox Code Playgroud)

这是我的地址类

    @Embeddable
    public class Address 
    {
   private String Street;
   private String City;
   private String State;
   private String PinCode;

       // Setters and Getters Below
     }
Run Code Online (Sandbox Code Playgroud)

我使用独立的Java类来尝试插入我的MySQL数据库.因为,我是Hibernate的新手,我只想使用这个注释而不是现在的关系.

我的独立Java类名为HibernateTest.java

       public class HibernateTest 
       {


      public static void main(String[] args) 
          {
    UserDetails user = new UserDetails();
    Address addr = new …
Run Code Online (Sandbox Code Playgroud)

java hibernate exception

2
推荐指数
1
解决办法
4781
查看次数

标签 统计

java ×3

hibernate ×2

exception ×1

field ×1

orm ×1

transient ×1