hibernate 的many to one 的问题IllegalArgumentException occurred while calling setter of hibernatePOJO

package com.oyth.model;


public class Book {
private int BookID;
private String BookName;
private BookType BookType; //注意此处必须是一个类对象。
private String BookAuthor;
private float BookPrice = 0.0f;
private String BookMshu;
private int BookCcun;
private String BookImage;

public int getBookID() {
return BookID;
}
public void setBookID(int bookID) {
BookID = bookID;
}
public String getBookName() {
return BookName;
}
public void setBookName(String bookName) {
BookName = bookName;
}

public String getBookAuthor() {
return BookAuthor;
}
public void setBookAuthor(String bookAuthor) {
BookAuthor = bookAuthor;
}
public float getBookPrice() {
return BookPrice;
}
public void setBookPrice(float bookPrice) {
BookPrice = bookPrice;
}
public String getBookMshu() {
return BookMshu;
}
public void setBookMshu(String bookMshu) {
BookMshu = bookMshu;
}
public int getBookCcun() {
return BookCcun;
}
public void setBookCcun(int bookCcun) {
BookCcun = bookCcun;
}
public String getBookImage() {
return BookImage;
}
public void setBookImage(String bookImage) {
BookImage = bookImage;
}
public BookType getBookType() {
return BookType;
}
public void setBookType(BookType bookType) {
BookType = bookType;
}


}

booktype类。

package com.oyth.model;


import java.util.HashSet;
import java.util.Set;


import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;








public class BookType {

private Integer BookTypeID;
private String BookTypeName;
private Set books =new HashSet();;


public Integer getBookTypeID() {
return BookTypeID;
}
public void setBookTypeID(Integer bookTypeID) {
BookTypeID = bookTypeID;
}
public String getBookTypeName() {
return BookTypeName;
}
public void setBookTypeName(String bookTypeName) {
BookTypeName = bookTypeName;
}



public Set getBooks() {
return books;
}
public void setBooks(Set books) {
this.books = books;
}




}


Book.hbm.xml













                     column="BookTypeID" 
                     class="com.oyth.model.BookType"
                     cascade="all"
                     outer-join="true"
                     lazy="false"/>   
















     






BookType.hbm.xml




















//出现上述问题的原因可能是由于在Book类中没有定义BookType类对象,注意查看@

你可能感兴趣的:(ssh)