• 大小: 26.27MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-22
  • 语言: Java
  • 标签: spring  hibernate  

资源简介

基于java语言,spring mvc+hibernate联合开发,mysql数据库,设置登录过滤器,错误拦截器,在必要填写字段设置啦字段长度判断,在学号工号等唯一字段进行检测,合理的数据库映射关系,在一些操作做到啦级联管理

资源截图

代码片段和文件信息

package mm.dao;

import mm.entity.Course;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/5/4 0004.
 */
@Repository
public class CourseDao {
    @Resource
    private static SessionFactory sessionFactory;
    private static Session session;
    private static Transaction transaction;
    static {
        Configuration configuration = new Configuration().configure();
        ServiceRegistry serviceRegistry =
                new ServiceRegistryBuilder().applySettings(configuration.getProperties())
                        .buildServiceRegistry();
        sessionFactory = configuration.buildSessionFactory(serviceRegistry);



    }
    private Session getSession(){
        if (session == null)
            session = sessionFactory.openSession();

        return session;
    }
    public void updatecourse(Course course){

        this.getSession().merge(course);

    }

    public void addcourse(Course course){
        transaction = session.beginTransaction();
        this.getSession().save(course);
        session.getTransaction().commit();
    }

    public object selectbyid(int id){
        return getSession().get(Course.classid);
    }
    public void deletecourse(int id){
        transaction = session.beginTransaction();
        this.getSession().createQuery(“delete Course where id=?“).setParameter(0 id).executeUpdate();
        session.getTransaction().commit();
    }
    public List getcourse(){
        return this.getSession().createQuery(“from Course c“).list();
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件          51  2017-06-14 16:29  新建文本文档.txt
     目录           0  2017-05-08 16:13  graduate\
     目录           0  2017-06-14 18:33  graduate\.idea\
     文件           8  2017-04-21 15:01  graduate\.idea\.name
     目录           0  2017-05-08 16:13  graduate\.idea\artifacts\
     文件        7831  2017-05-08 16:13  graduate\.idea\artifacts\graduate_war_exploded.xml
     文件         393  2017-04-28 16:54  graduate\.idea\codestyleSettings.xml
     文件         685  2017-06-07 10:12  graduate\.idea\compiler.xml
     目录           0  2017-04-21 15:01  graduate\.idea\copyright\
     文件          76  2017-04-21 15:01  graduate\.idea\copyright\profiles_settings.xml
     文件         334  2017-04-25 13:27  graduate\.idea\encodings.xml
     目录           0  2017-04-25 15:28  graduate\.idea\libraries\
     文件         270  2017-04-25 10:45  graduate\.idea\libraries\hiberlate.xml
     文件        7254  2017-04-25 15:28  graduate\.idea\libraries\Spring_4_3_8_RELEASE.xml
     文件         873  2017-04-24 16:38  graduate\.idea\misc.xml
     文件         256  2017-04-21 15:02  graduate\.idea\modules.xml
     文件        8792  2017-04-21 15:20  graduate\.idea\uiDesigner.xml
     文件       97882  2017-06-14 18:33  graduate\.idea\workspace.xml
     文件        7173  2017-05-08 16:13  graduate\graduate.iml
     目录           0  2017-04-22 22:14  graduate\out\
     目录           0  2017-04-21 15:11  graduate\out\artifacts\
     目录           0  2017-06-14 15:54  graduate\out\artifacts\graduate_war_exploded\
     文件        3343  2017-05-20 21:51  graduate\out\artifacts\graduate_war_exploded\admin.jsp
     文件        2991  2017-05-20 21:39  graduate\out\artifacts\graduate_war_exploded\admin_s.jsp
     文件        3173  2017-05-20 21:51  graduate\out\artifacts\graduate_war_exploded\admin_t.jsp
     文件         503  2017-05-10 13:45  graduate\out\artifacts\graduate_war_exploded\errorpage.jsp
     目录           0  2017-05-10 13:41  graduate\out\artifacts\graduate_war_exploded\image\
     文件       65507  2017-05-09 18:36  graduate\out\artifacts\graduate_war_exploded\image\01.jpg
     文件       65507  2017-05-09 18:36  graduate\out\artifacts\graduate_war_exploded\image\02.jpg
     文件       82055  2017-05-10 13:41  graduate\out\artifacts\graduate_war_exploded\image\404.png
     文件        4548  2017-06-02 13:37  graduate\out\artifacts\graduate_war_exploded\index.jsp
............此处省略233个文件信息

评论

共有 条评论