SSM框架练习—主从表的业务模型

2023-11-06

需要实现的整体功能:

  1. 系统的登录并进行用户名的校验
  2. 团购信息的列表展示
  3. 团购信息的添加
  4. 团购信息的检索

1、数据库创建

CREATE DATABASE mydb;

USE mydb;


drop table if exists vaccunit;

CREATE TABLE vaccunit (
  vid INT AUTO_INCREMENT PRIMARY KEY,
  unitname VARCHAR(50) NOT NULL,
  address VARCHAR(50) NOT NULL
);

insert into vaccunit(unitname,address) values('柏林卫生院','中原区');
insert into vaccunit(unitname,address) values('社区卫生院','金水区');
insert into vaccunit(unitname,address) values('第一医院','二七区');


drop table if exists appointment;

CREATE TABLE appointment (
  aid INT AUTO_INCREMENT PRIMARY KEY,
  person VARCHAR(32) NOT NULL,
  phone VARCHAR(11) NOT NULL,
  ipcard VARCHAR(18) NOT NULL,
  birthday DATETIME NOT NULL,
  sex VARCHAR(10) NOT NULL,
  vid INT NOT NULL,
  FOREIGN KEY (vid) REFERENCES vaccunit(vid)
);

insert into appointment values (1,'张三','1364758374','40038312345678','2020-01-01','男',1);
insert into appointment values (2,'李四','136423374','40038312345678','2020-01-01','女',2);
insert into appointment values (3,'王五','1364758374','40038312345678','2020-01-01','男',3);


select * from vaccunit;
select * from appointment;

#查询所有预约1号医院(柏林)预约医院
select * from appointment where vid=1;

#使用聚合函数统计查询数据数量
select count(*) from appointment where vid=1;

2、框架搭建,创建项目,导入jar包,创建实体类;

 1.springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <context:component-scan base-package="com.zhan.controller"/>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <mvc:resources mapping="/css/**" location="/css/"/>
    <mvc:resources mapping="/js/**" location="/js/"/>
    <mvc:resources mapping="/fonts/**" location="/fonts/"/>
    <mvc:resources mapping="/img/**" location="/img/"/>

    <mvc:annotation-driven/>

</beans>

2.spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd">
    <context:component-scan base-package="com.zhan">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/mydb"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
    </bean>

    <bean id="factoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="typeAliasesPackage" value="com.zhan.bean"/>
        <property name="configLocation" value="classpath:mybatis.xml"/>
    </bean>

    <bean id="scannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.zhan.dao"/>
    </bean>

</beans>

3.mybatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <setting name="logImpl" value="log4j"/>
    </settings>

</configuration>

4.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring.xml</param-value>
    </context-param>

    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcherServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

配置完成后,测试是否能够运行成功;

index.jsp首页

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>首页</title>
  </head>
  <body>
  <a href="findAll">去登录</a>
  </body>
</html>

zhuye.jsp主页

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主页</title>
</head>
<body>
<h2>欢迎来到主页!</h2>
</body>
<table>
    <thead>
    <tr>
        <th>接种单位</th>
        <th>预约人</th>
        <th>电话</th>
        <th>身份证</th>
        <th>生日</th>
        <th>性别</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    
    </tbody>
</table>
</html>

controller层的AppointmentController

@Controller
public class AppointmentController {

    @RequestMapping("/findAll")
    public ModelAndView findAll(){
        ModelAndView mv = new ModelAndView();
        System.out.println("findAll执行");
        mv.setViewName("zhuye");
        return mv;
    }
}

运行后,测试成功; 

 

 3、当页面第一次加载时,显示所有的预约列表。 在列表中,需要显示列“接种单位”、“预约人”、“电话”、“身份证”、“生日”、“性别”、“操作”。

1.全查 

 dao层AppointmentDao

@Repository
public interface AppointmentDao {
    List<Appointment> selectAll();
}

dao层VaccunitDao

@Repository
public interface VaccunitDao {
    @Select("select * from vaccunit where vid=#{vid}")
    Vaccunit selectById(int vid);
}

dao层AppointmentDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhan.dao.AppointmentDao">
    <resultMap id="amMap" type="com.zhan.bean.Appointment">
        <id property="aid" column="aid"/>
        <result property="person" column="person"/>
        <result property="phone" column="phone"/>
        <result property="ipcard" column="ipcard"/>
        <result property="birthday" column="birthday"/>
        <result property="sex" column="sex"/>
        <association property="vaccunit" column="vid" select="com.zhan.dao.VaccunitDao.selectById"></association>
    </resultMap>
    <select id="selectAll" resultMap="amMap">
        select * from appointment;
    </select>
</mapper>

service层AppointmentService

@Service
public interface AppointmentService {
    List<Appointment> selectAll();
}

 service层VaccunitService

public interface VaccunitService {
    Vaccunit selectById(int vid);
}

service层impl.AppointmentServiceImpl

@Service
public class AppointmentServiceImpl implements AppointmentService {
    @Autowired
    AppointmentDao appointmentDao;

    @Override
    public List<Appointment> selectAll() {
        return appointmentDao.selectAll();
    }
}

 service层impl.VaccunitServiceImpl

@Service
public class VaccunitServiceImpl implements VaccunitService {
    @Autowired
    VaccunitDao vaccunitDao;

    @Override
    public Vaccunit selectById(int vid) {
        return vaccunitDao.selectById(vid);
    }
}

 controller层的AppointmentController

@Controller
public class AppointmentController {
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    VaccunitService vaccunitService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(){
        ModelAndView mv = new ModelAndView();
//        System.out.println("findAll执行");
        List<Appointment> appointmentList = appointmentService.selectAll();
//        System.out.println(appointmentList);
        mv.addObject("appointmentList",appointmentList);
        mv.setViewName("zhuye");
        return mv;
    }
}

zhuye.jsp主页

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>主页</title>
</head>
<body>
<h2>欢迎来到主页!</h2>
<table>
    <thead>
    <tr>
        <th>接种单位</th>
        <th>预约人</th>
        <th>电话</th>
        <th>身份证</th>
        <th>生日</th>
        <th>性别</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${appointmentList}" var="appointment">
        <tr>
            <td><a href="findByVid?vid=${appointment.vaccunit.vid}">${appointment.vaccunit.unitname}</a>
            </td>
            <td>${appointment.person}</td>
            <td>${appointment.phone}</td>
            <td>${appointment.ipcard}</td>
            <td>${appointment.birthday}</td>
            <td>${appointment.sex}</td>
            <td>
                <a href="del?aid=${appointment.aid}">删除</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>

新增

  • 添加页面的接种单位需要从后台查询并使用下列列表显示。
  • 当缺陷预约成功之后,跳转到列表页面。
dao层AppointmentDao
@Repository
public interface AppointmentDao {
    int insert(Appointment appointment);
}

dao层AppointmentDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhan.dao.AppointmentDao">
    <resultMap id="amMap" type="com.zhan.bean.Appointment">
        <id property="aid" column="aid"/>
        <result property="person" column="person"/>
        <result property="phone" column="phone"/>
        <result property="ipcard" column="ipcard"/>
        <result property="birthday" column="birthday"/>
        <result property="sex" column="sex"/>
        <association property="vaccunit" column="vid" select="com.zhan.dao.VaccunitDao.selectById"></association>
    </resultMap>
    <insert id="insert" parameterType="com.zhan.bean.Appointment">
        insert into appointment(person,phone,ipcard,birthday,sex,vid)
        values (#{person},#{phone},#{ipcard},#{birthday},#{sex},#{vaccunit.vid});
    </insert>
</mapper>

service层AppointmentService

@Service
public interface AppointmentService {
    int insert(Appointment appointment);
}

service层impl.AppointmentServiceImpl

@Service
public class AppointmentServiceImpl implements AppointmentService {
    @Autowired
    AppointmentDao appointmentDao;

    @Override
    public int insert(Appointment appointment) {
        return appointmentDao.insert(appointment);
    }
}

 controller层的AppointmentController

@Controller
public class AppointmentController {
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    VaccunitService vaccunitService;


    @RequestMapping("/add")
    public ModelAndView insert(Appointment appointment){
        ModelAndView mv = new ModelAndView();
//        System.out.println(appointment);
        int n = appointmentService.insert(appointment);
        if(n>0){
            mv.setViewName("redirect:/findAll");
        }else{
            mv.setViewName("error");
        }
        return mv;
    }

    @RequestMapping("/del")
    public ModelAndView del(int aid){
        ModelAndView mv = new ModelAndView();
        int n = appointmentService.delete(aid);
        System.out.println(n);
        mv.setViewName("redirect:/findAll");
        return mv;
    }
}

zhuye.jsp主页

<h2>欢迎来到主页!</h2>
<h3>
    <a href="add.jsp">预约</a>
</h3>

add.jsp添加页

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加页</title>
</head>
<body>
<form action="add" method="post">
    接种单位:
    <select id="type" name="vaccunit.vid">
        <option value="1">柏林卫生院</option>
        <option value="2">社区卫生院</option>
        <option value="3">第一医院</option>
    </select><br>
    预约人:<input type="text" name="person" id="person" value=""><br>
    电话:<input type="text" name="phone" id="phone" value=""><br>
    身份证:<input type="text" name="ipcard" id="ipcard" value=""><br>
    生日:<input type="text" name="birthday" id="birthday" value=""><br>
    性别:<input type="radio" name="sex" value="男">男
    <input type="radio" name="sex" value="女">女<br>
    <button type="submit" id="btn">预约</button>
</form>
</body>
</html>

删除

dao层AppointmentDao

@Repository
public interface AppointmentDao {
    int delete(int aid);
}

dao层AppointmentDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhan.dao.AppointmentDao">
    <resultMap id="amMap" type="com.zhan.bean.Appointment">
        <id property="aid" column="aid"/>
        <result property="person" column="person"/>
        <result property="phone" column="phone"/>
        <result property="ipcard" column="ipcard"/>
        <result property="birthday" column="birthday"/>
        <result property="sex" column="sex"/>
        <association property="vaccunit" column="vid" select="com.zhan.dao.VaccunitDao.selectById"></association>
    </resultMap>

    <delete id="delete" parameterType="int">
         delete from appointment where aid=#{aid};
    </delete>
</mapper>

service层AppointmentService

@Service
public interface AppointmentService {
    int delete(int aid);
}

service层impl.AppointmentServiceImpl

@Service
public class AppointmentServiceImpl implements AppointmentService {
    @Autowired
    AppointmentDao appointmentDao;

    @Override
    public int delete(int aid) {
        return appointmentDao.delete(aid);
    }
}

 controller层的AppointmentController

@Controller
public class AppointmentController {
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    VaccunitService vaccunitService;

    @RequestMapping("/del")
    public ModelAndView del(int aid){
        ModelAndView mv = new ModelAndView();
        int n = appointmentService.delete(aid);
        System.out.println(n);
        mv.setViewName("redirect:/findAll");
        return mv;
    }
}

zhuye.jsp主页

            <td>
                <a href="del?aid=${appointment.aid}">删除</a>
            </td>

统计

  • 详情界面能够正确显示接种单位和单位地址。
  • 并能够正确显示预约人数。

dao层AppointmentDao

@Repository
public interface AppointmentDao {
    int count(int vid);
}

dao层AppointmentDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhan.dao.AppointmentDao">
    <resultMap id="amMap" type="com.zhan.bean.Appointment">
        <id property="aid" column="aid"/>
        <result property="person" column="person"/>
        <result property="phone" column="phone"/>
        <result property="ipcard" column="ipcard"/>
        <result property="birthday" column="birthday"/>
        <result property="sex" column="sex"/>
        <association property="vaccunit" column="vid" select="com.zhan.dao.VaccunitDao.selectById"></association>
    </resultMap>
    <select id="count" parameterType="int" resultType="int">
        select count(*) from appointment where vid=#{vid};
    </select>
</mapper>

service层AppointmentService

@Service
public interface AppointmentService {
    int count(int vid);
}

service层impl.AppointmentServiceImpl

@Service
public class AppointmentServiceImpl implements AppointmentService {
    @Autowired
    AppointmentDao appointmentDao;

    @Override
    public int count(int vid) {
        return appointmentDao.count(vid);
    }
}

 controller层的AppointmentController

@Controller
public class AppointmentController {
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    VaccunitService vaccunitService;

    @RequestMapping("/findByVid")
    public ModelAndView findByVid(int vid){
        ModelAndView mv = new ModelAndView();
        //根据Vid查询医院信息
        Vaccunit vaccunit = vaccunitService.selectById(vid);
        //根vid查询该医院预约信息的计数数量
        int count = appointmentService.count(vid);
        mv.addObject("vaccunit",vaccunit);
        mv.addObject("count",count);
        mv.setViewName("show");
        return mv;
    }
}

zhuye.jsp主页 

    <select id="type" name="vaccunit.vid">
        <option value="1">柏林卫生院</option>
        <option value="2">社区卫生院</option>
        <option value="3">第一医院</option>
    </select>

模糊查询

dao层AppointmentDao 

@Repository
public interface AppointmentDao {
    List<Appointment> seach(Appointment appointment);
}

dao层AppointmentDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhan.dao.AppointmentDao">
    <resultMap id="amMap" type="com.zhan.bean.Appointment">
        <id property="aid" column="aid"/>
        <result property="person" column="person"/>
        <result property="phone" column="phone"/>
        <result property="ipcard" column="ipcard"/>
        <result property="birthday" column="birthday"/>
        <result property="sex" column="sex"/>
        <association property="vaccunit" column="vid" select="com.zhan.dao.VaccunitDao.selectById"></association>
    </resultMap>
    <select id="seach" parameterType="com.zhan.bean.Appointment" resultMap="amMap">
        select * from appointment where vid=#{vaccunit.vid} and person like concat('%',#{person},'%');
    </select>
</mapper>

service层AppointmentService

@Service
public interface AppointmentService {
    List<Appointment> seach(Appointment appointment);
}

service层impl.AppointmentServiceImpl

@Service
public class AppointmentServiceImpl implements AppointmentService {
    @Autowired
    AppointmentDao appointmentDao;

    @Override
    public List<Appointment> seach(Appointment appointment) {
        return appointmentDao.seach(appointment);
    }
}

 controller层的AppointmentController

@Controller
public class AppointmentController {
    @Autowired
    AppointmentService appointmentService;
    @Autowired
    VaccunitService vaccunitService;

    @RequestMapping("/seach")
    public ModelAndView seach(Appointment appointment){
        ModelAndView mv = new ModelAndView();
        List<Appointment> appointmentList = appointmentService.seach(appointment);
        System.out.println(appointmentList);
        mv.addObject("appointmentList",appointmentList);
        mv.setViewName("zhuye");
        return mv;
    }
}

zhuye.jsp主页

<form action="seach" method="post">
    <select id="type" name="vaccunit.vid">
        <option value="1">柏林卫生院</option>
        <option value="2">社区卫生院</option>
        <option value="3">第一医院</option>
    </select>
    <input type="text" name="person" value="" placeholder="请输入姓名">
    <input type="submit" value="搜索">
</form>

页面展示

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SSM框架练习—主从表的业务模型 的相关文章

  • 在哈希图中存储字符和二进制数

    我正在尝试存储字母到二进制数的映射 这是我的映射 h 001 i 010 k 011 l 100 r 101 s 110 t 111 为此 我创建了一个哈希映射并存储了键值对 我现在想显示给定句子的相应二进制值 这是我的代码 package
  • 如何在数据库中对 (Java) 枚举进行建模(使用 SQL92)

    您好 我正在使用名为 性别 的列对实体进行建模 在应用程序代码中 性别应该是一个 Java 枚举类型 有 2 个值 男性和女性 知道作为数据类型的枚举不是通用 SQL 语言 92 的一部分 您将如何建模它 数据模型必须是可移植的 以便由多个
  • 如何屏蔽 Protobuf 中的某些字段

    我找不到一种方法来屏蔽 protobuf 结构中的某些字段 我确实阅读了有关 FieldMaskUtil 的内容并尝试了几个示例 但它似乎做了相反的操作 即复制 FieldMask 中提到的字段 这与我想要的不同 这是示例结构和相应的测试代
  • 更改 JTextPane 的大小

    我是Java新手 刚刚在StackOverflow中找到了这段代码 ResizeTextArea https stackoverflow com questions 9370561 enabling scroll bars when jte
  • Hystrix是否可以订阅CircuitBreaker开启事件?

    对于单元测试 我希望能够订阅 Hystrix 事件 特别是在断路器打开或关闭时发生事件 我四处寻找示例 似乎解决方法是利用指标流并监视断路器标志 由于 Hystrix 是基于 RxJava 构建的 我认为应该在某个地方有一个事件订阅接口 在
  • 如何在Gradle中支持多种语言(Java和Scala)的多个项目?

    我正在尝试将过时的 Ant 构建转换为 Gradle 该项目包含约50个Java子项目和10个Scala子项目 Java 项目仅包含 Java Scala 项目仅包含 Scala 每个项目都是由 Java 和 Scala 构建的 这大大减慢
  • 中间件 API 的最佳实践是什么? [关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我们正在开发一个中间件 SDK 采用 C 和 Java 语言 供游戏开发人员 动画软件开发人员 阿凡达开
  • Scala(或 Java)中泛型函数的特化

    是否可以在 Scala 中专门化泛型函数 或类 例如 我想编写一个将数据写入 ByteBuffer 的通用函数 def writeData T buffer ByteBuffer data T buffer put data 但由于 put
  • Oracle 查询向上或向下舍入到最近的 15 分钟间隔

    08 SEP 20 08 55 05 08 SEP 20 15 36 13 下面的查询对于 15 36 13 可以正常工作 因为它四舍五入到 15 30 但 8 55 05 向下舍入到 08 45 而它应该四舍五入到 09 00 selec
  • 膨胀类片段 InflateException 二进制 XML 文件时出错

    我正在使用 Material Design 和 NavigationDrawer 布局等设计我的第一个应用程序 但我遇到了一个问题 该应用程序非常简单 它只显示文本 并且基于 Android Studio 中提供的模板 尝试启动我的应用程序
  • 如何使用 Hibernate Session.doWork(...) 进行保存点/嵌套事务?

    我正在使用 JavaEE JPA 托管事务与 Oracle DB 和 Hibernate 并且需要实现某种嵌套事务 据我所知 此类事情不受开箱即用的支持 但我应该能够为此目的使用保存点 正如建议的https stackoverflow co
  • Java 8根据Map属性过滤Map对象列表以删除一些重复项

    Have a List
  • 在单个查询中设置和选择?

    我想知道是否可以在单个查询中设置和选择 像这样的事情 SET LOCAL search path TO 1 SET LOCAL ROLE user SELECT from posts 你可以这样做 with some set as sele
  • 设计抽象类时是否应该考虑序列化问题?

    一般来说这个问题来自Eclipse建议在抽象类上添加串行版本UID 由于该类是抽象类 因此该类的实例永远不会存在 因此它们永远不会被序列化 只有派生类才会被序列化 所以我的问题是放置一个安全 SuppressWarnings serial
  • 如何使用 SAX Java 解析器读取注释文本

    我只想使用 Java 中的 SAX 解析器读取 XML 文件中对象标记的注释 这是我的文件的摘要
  • BoneCP 和 Derby - 如何正确关闭

    I have BoneCP CONNECTION POOL CONNECTION POOL getConfig setJdbcUrl jdbc derby database shutdown true Connection connecti
  • Java中的媒体播放器库[关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我正在评估用于在 Java 中播放音频 视频的库 它不需要 100 Java Java 与本机库的绑定
  • 当我在 Java 中输入 IP 时无法连接到我的服务器

    好的 我正在尝试学习 Java 客户端 服务器的内容 并且正在浏览教程代码 如下所示 当我将 localhost 更改为我的 IP 时 它会停止工作 请帮忙 编辑 127 0 0 1 似乎也可以工作 但不是我的真实IP Copyright
  • 条件查询:按计数排序

    我正在尝试执行一个标准查询 该查询返回 stackoverflow 中回答最多的问题 例如常见问题解答 一个问题包含多个答案 我正在尝试使用标准查询返回按每个问题的答案数排序的回答最多的问题 任何人都知道我应该在 hibernate cri
  • Java:基于 Web 的应用程序中的单例类实例

    我在 Web Application 中有这个 Singleton 类 public class MyDAO private static MyDAO instance private MyDAO public static MyDAO g

随机推荐

  • MyBatis与JDBC连接数据库所使用的url之间的差异

    1 在JDBC连接里是这样的 连接无误 2 在Mybatis里配置要这样 3 主要区别 说明 JDBC 方式连接 MySQL 不需要对 进行转义 而在Mybatis里要求一定要对 转义 4 如果是在properties文件里 不用转义的 在
  • IP静态路由实验报告

    一 将192 168 1 0 24划分为4个网段 192 168 1 0 26 192 168 1 64 26 192 168 1 128 26 192 168 1 192 26 1 取192 168 1 0 26继续划分 为主干道添加IP
  • Spring 加载、解析applicationContext.xml 流程

    概要 Spring 框架使用了BeanFactory 进行加载 xml 和生成 bean 实例 下面我们分析下Spring加载xml文件的过程 spring 版本是最新的 4 3 9 release 版本 示例 XmlBeanFactory
  • java 转换tif图片为jpg,解决转换后颜色异常问题

    java 转换tif图片为jpg 解决转换后颜色异常问题 说明 正常情况下 tif转换jpg图片会出现颜色失真 丢失部分颜色 原因是两种图片的色彩模式不同 jpg默认使用的是RGB色彩模式 TIF默认使用的是CMYK色彩模式 RGB的色域比
  • 有关“ModuleNotFoundError: No module named ‘flask._compat’”错误的解决过程

    在进行flask安装后 运行程序的过程中出现了 ModuleNotFoundError No module named flask compat 的错误 在查询了多个网站后给出了不同的答案 其报错原因是flask版本过高导致无法识别该语法
  • 仿京东 项目笔记2(注册登录)

    这里写目录标题 1 注册页面 1 1 注册 登录页面 接口请求 1 2 Vue开发中Element UI的样式穿透 1 2 1 v deep的使用 1 2 2 elementUI Dialog内容区域显示滚动条 1 3 注册页面 步骤条和表
  • 服务器i5 和e系列,e5和i5有什么区别

    两个系列的处理器主要在设计规格和面向范围方面存在区别 设计规格上 前者核心数更多 多线程能力更强 但睿频能力相对较弱 后者核心数较少 多线程能力不如前者 但睿频能力更强 面向范围上 前者主要面向服务器 嵌入式等企业设备 后者主要面向消费级硬
  • (LeetCode)全排列

    目录 题目要求 题目理解以及思路分析 代码分部讲解 第一部分 第二部分 题目要求 给定一个不含重复数字的数组 nums 返回其 所有可能的全排列 你可以 按任意顺序 返回答案 示例 1 输入 nums 1 2 3 输出 1 2 3 1 3
  • 规则引擎Drools使用 第十一篇 Drools 的高级语法之LHS增强

    前面我们已经知道了在规则体中的LHS部分是介于when和then之间的部分 主要用于模式匹配 只有匹配结果为true时 才会触发RHS部分的执行 下面我们会针对LHS部分学习几个新的用法 目录 复合值限制in not in 条件元素eval
  • 升压电路(BOOST)与降压电路(BUCK)

    一 电路中产生电流的条件是 1 电路里必须有电源供电 2 电路必须形成闭合回路 降压元器件 升降压电路构成的核心元器件 1 电感 储存能量 电感是无法突变的 工作状态是线性的 2 二极管 3 mos管 首先先分清楚mos是N mos还是P
  • Qt全局宏和变量

    1 Qt 全局宏定义 Qt版本号 QT VERSION major lt lt 16 minor lt lt 8 patch 检测版本号 QT VERSION CHECK major minor patch major lt lt 16 m
  • virtio代码分析(一)-qemu部分

    virtio内容众多 代码分布于qemu linux dpdk等中 而且分为frontend和backend 可以运行于userspace也可以运行于kernelspace 极其难以理解 不看代码只看原理性文档往往流于表面 只有真正看懂了代
  • 大数据准备——安装JDK

    1 解压Linux版本的JDK压缩包 命令行敲入 mkdir home software cd home software rz 上传jdk tar包 这里添加自己tar包的名字 如果rz命令不能使用 先执行yum install lrzs
  • C语言关键字解析

    在C语言中有32个关键字 如下表所示 释 1 声明 1 告诉编译器 这个名字已经匹配到一块内存上 2 告诉编译器 这个名字已经预定了 其他地方再也不能用它来作为变量名或对象名 2 定义 编译器创建一个对象 为这个对象分配一块内存空间 并给它
  • 前端 配色网站 自用 免费 颜色很全

    1 中国色彩 http zhongguose com 3 ColorHex https www colorhexa com 4 优色网配色专区 https color uisdc com 4 ColorDrop https www colo
  • cuda学习

    GPU中有多个流处理器SM 当一个线程块被指定给一个SM后 里面的线程会被划分成线程束 32个线程 在SM上交替运行 也就是说SM上一个时刻只有一个线程束在运行 函数修饰符 global 表示该函数只能在GPU上运行 但是可以从CPU或者G
  • qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method

    最近在做一个网络音乐播放器时 由于出现qt network ssl QSslSocket cannot call unresolved function SSLv23 client method 而不能播放网络歌曲 上网搜了半天 都说要在电
  • Jmeter(二十七) - 从入门到精通 - Jmeter Http协议录制脚本(详解教程)

    1 简介 LoadRunner的录制功能让性能测试脚本编写对于不懂代码的人变成了一件容易上手的事 但是由于LoadRunner收费高昂 庞大 一般企业很少用 除非必须使用 Jmeter作为性能测试中的王者也少不了提供录制功能 Jmeter的
  • 靠!我被项目经理和同事嘲笑了,因为不会远程debug调试...

    大家好 我是曹尼玛 刚从培训机构毕业 去一家单位上班一周了 这一周项目经理让我熟悉了项目业务 架构和设计 不算难 凭借我培训机构第一名的成绩 还是很顺溜 今天项目经理把同事们叫到一起 说线上438x6项目出现奇葩问题 但是开发环境初步测试没
  • SSM框架练习—主从表的业务模型

    需要实现的整体功能 系统的登录并进行用户名的校验 团购信息的列表展示 团购信息的添加 团购信息的检索 1 数据库创建 CREATE DATABASE mydb USE mydb drop table if exists vaccunit C