错误代码如下log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: ynu.edu.cn.Pricetype.machinesById
其他的错误代码就不发了.....@Entity
@Table(catalog = "wangba", name = "pricetype")
public class Pricetype {
private int id;@Id
@Column(name = "ID", nullable = false, length = 10)
public int getId() {
return id;
}public void setId(int id) {
this.id = id;
}private double price;@Basic
@Column(name = "price", length = 4, precision = 2)
public double getPrice() {
return price;
}public void setPrice(double price) {
this.price = price;
}private ArrayList<Machine> machinesById;@OneToMany(mappedBy = "pricetypeByPricetype")
public ArrayList<Machine> getMachinesById() {
return machinesById;
}public void setMachinesById(ArrayList<Machine> machinesById) {
this.machinesById = machinesById;
}}上面是用idea自动生成的,我把collection改成了arraylist类型..程序中的HibernateSessionFactory类,似乎是myeclipse自动生成的单件模式的类,我把它拷过来,并将其中的Configuration改成了AnnotationConfiguration,其他基本没变....不知道是什么原因...希望大家指点一下...第一次自己写hibernate程序......
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: ynu.edu.cn.Pricetype.machinesById
其他的错误代码就不发了.....@Entity
@Table(catalog = "wangba", name = "pricetype")
public class Pricetype {
private int id;@Id
@Column(name = "ID", nullable = false, length = 10)
public int getId() {
return id;
}public void setId(int id) {
this.id = id;
}private double price;@Basic
@Column(name = "price", length = 4, precision = 2)
public double getPrice() {
return price;
}public void setPrice(double price) {
this.price = price;
}private ArrayList<Machine> machinesById;@OneToMany(mappedBy = "pricetypeByPricetype")
public ArrayList<Machine> getMachinesById() {
return machinesById;
}public void setMachinesById(ArrayList<Machine> machinesById) {
this.machinesById = machinesById;
}}上面是用idea自动生成的,我把collection改成了arraylist类型..程序中的HibernateSessionFactory类,似乎是myeclipse自动生成的单件模式的类,我把它拷过来,并将其中的Configuration改成了AnnotationConfiguration,其他基本没变....不知道是什么原因...希望大家指点一下...第一次自己写hibernate程序......
解决方案 »
- JSP通过servlet获取结果集
- Ajax的简单问题!!
- 高分求救,一个JavaScript事件的问题!
- 救命呀,小弟有麻烦了!
- 在网页中如何捕获ActiveX控件发出的事件?--急
- Cookie设置超时问题
- 这个java错误是什么意思啊?为什么会出这种问题?
- 关于一个JDBC的ResultSet的问题!!(在线等待)
- 请教高手,如何在WIN2K上配置JSP运行环境??
- query.createSqlQuery 与query.createNativeQuery 的区别
- 谁能看看这段用commons upload做的上传程序哪里有问题
- 用commons.fileupload控件已经实现上传功能,但是在局域网内上传速度与外网的上传速度一样,想让在局域网内上传速度更快一些
这里用了泛型,和Collection没有继承关系了
我这个产生的应该跟javabean没区别吧...
为什么
<c:forEach var="pricetype" items="${priceTypes}">
<optgroup label="${pricetype.price}元的机器区">
利用javabean时没有错误,可是现在我用hibernate产生的东西(类似javabean)就出现错误说
_jspx_exception = {java.lang.NumberFormatException@4033}"java.lang.NumberFormatException: For input string: \"price\""
希望指点下!!!
检查你的数据。
"price" 是字符串,不能转化为 Number 哦!你参数赋值错了。
private double price; @Basic
@Column(name = "price", length = 4, precision = 2)
public double getPrice() {
return price;
} public void setPrice(double price) {
this.price = price;
} 那该怎么改呢???
呵呵,好像hibernate产生的不能直接赋值哦...
ArrayList<Pricetype> priceTypes = (ArrayList<Pricetype>) application.getAttribute("priceTypes");
pricetype = new Pricetype();
pricetype = priceTypes.get(0);//出错红色的部分也是一个hibernate产生的javabean的类的集合...所以这样也就导致jstl也会出错....但是还是不清楚怎么改...
log4j:WARN Please initialize the log4j system properly
这个问题要怎么解决啊
这里用了泛型,和Collection没有继承关系了
这个我会 没有log4j文件 对于这个annotations版本