admin0_1 2019-06-13 23:06
浏览 309

一直报错这个 attempt to create saveOrUpdate event with null entity 求助 快逼疯了

实体类
package com.user.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="clas")
public class Student {

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@Column(length=600,nullable=false)
private String name;
@Column(length=600,nullable=false)
private String desc;
@Column(length=600,nullable=false)
private String remark;


public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getClas() {
    return name;
}
public void setClas(String clas) {
    this.name = clas;
}
public String getDesc() {
    return desc;
}
public void setDesc(String desc) {
    this.desc = desc;
}
public String getRemark() {
    return remark;
}
public void setRemark(String remark) {
    this.remark = remark;
}

}

dao里面
package com.user.dao.impl;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.user.bean.Student;
@Repository
public class IStudentDao extends HibernateDaoSupport implements com.user.dao.IStudentDao {
@Resource(name="sessionFactory")
public void setHibernateSessionFactroy(SessionFactory sessionFactory){
this.setSessionFactory(sessionFactory);
}

//添加分类
public void addStudent(Student student) {
    // TODO Auto-generated method stub
    this.getHibernateTemplate().save(student);


}

}

service里面

package com.user.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.user.dao.IStudentDao;
import com.user.bean.Student;
@Service
public class StudentService implements com.user.service.StudentService {
@Resource
private IStudentDao studentDao;

@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
public void addStudent(Student student) {
    // TODO Auto-generated method stub
    studentDao.addStudent(student);

}

}

Action里面

package com.user.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.user.bean.Student;
import com.user.service.StudentService;

@Controller
@Scope("prototype")
public class StudentAction {
@Resource
private StudentService studentService;
private Student student;

//查询分类管理
public String list() {
    return "list";
}
//到添加的页面
public String toAddpage() {

    return "toAddpage";                                                                                                                                                                
}
//添加的方法
public String add() {
    studentService.addStudent(student);
    return "add";
}

}

jsp里面

分类名称
10字以内...
分类描述
10字以内...
备注
250字以内...
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BDSBAS-B1C和B1C信号有什么不同
    • ¥15 在半圆平面内随机生成点坐标
    • ¥15 系统容量变化的几种多址方式TDMA, CDMA,FDMA,OFDMA 对比,应该给的是一个曲线 图,随着系统容量的增加,几种多址方式性能的对比 图,MATLAB程序仿真折线图
    • ¥15 用visual Studio 写c ++只运行上一个旧代码的运行结果是怎么回事
    • ¥15 系统容量变化的几种多址方式(TDMA,FDMA,OFDMA,CDMA)对比(相关搜索:曲线图)
    • ¥15 worldclim 历史及未来气候数据矫正
    • ¥15 ajax服务器不能下载
    • ¥15 运用c++和opencv实现二维码的识别和三维坐标的建立
    • ¥100 理想汽车的ADB为什么到了国外换了SIM就可以打开?
    • ¥15 k210烧入flash报错error:2005