实体类

用实体类接收

匿名 (未验证) 提交于 2019-12-02 23:57:01
@RequestMapping ( "/saveorupdatebasegoodinfo" ) @ResponseBody public JSONResponse saveOrUpdateBaseGoodinfo ( @RequestBody Map < String , Object > map , HttpServletRequest request ) { JSONResponse jsonResponse = new JSONResponse (); HttpSession session = request . getSession ( false ); if ( session == null ) { throw new RuntimeException ( "session已经超时!" ); } Map < String , Object > firstMap =( Map < String , Object >) session . getAttribute ( "map" ); firstMap . putAll ( map ); GoodsBaseInfo goodsBaseInfo = new GoodsBaseInfo (); MapUtils . mapToJavaBean ( goodsBaseInfo , GoodsBaseInfo . class ,

Spring Boot 2.0 常见问题总结(二)

匿名 (未验证) 提交于 2019-12-02 23:55:01
使用 IDEA 生成 POJO 实体类 a. 使用 idea 连接上需要操作的数据库。 b. 选中要生成实体类的数据库表:右键 ---> Scripted Extensions ---> Generate POJOs.groovy。 c. 在弹出的窗口选择生成的位置即可。 application.properties 属性自动映射实体类配置 a. 在 application.properties 文件中定义的属性如下 wxpay.appid=wx5beac15ca207cdd40c wxpay.appsecret=5548012f33417fdsdsdd6f96b382fe548215e9 b.使用 @PropertySource(value = "classpath:application.properties") 即可。 @Getter @Setter @Configuration @PropertySource(value = "classpath:application.properties") public class WeChatConfig { @Value("${wxpay.appid}") private String appId; // 公众号 appid @Value("${wxpay.appsecret}") private String appsecret

实体类属性

匿名 (未验证) 提交于 2019-12-02 23:52:01
原文链接: http://www.cnblogs.com/Arvin-Lai/archive/2012/11/20/2778574.html 当用List<T> list=new List<T>();T为实体类绑定表格的时候,不想再去编辑columnheader的时候,可以在实体类属性中加入一些属性进行控制 class T { [Browsable(false)]//绑定表格中不可见 public int ID{get;set;} [DisplayName("姓名")]//该列头所显示的名称 public string Name{get;set;} } //还有很多属性可以用,暂时没怎么用到,具体可以查看 http://msdn.microsoft.com/zh-cn/library/z82ykwhb%28v=vs.90%29.aspx 转载于:https://www.cnblogs.com/Arvin-Lai/archive/2012/11/20/2778574.html 文章来源: https://blog.csdn.net/weixin_30830327/article/details/97272422

EntityFramework中实体类到表名的批量映射

匿名 (未验证) 提交于 2019-12-02 23:47:01
在使用EntityFramework做CodeFirst开发时,经常需要将实体类映射到数据库表,但是C#实体类和数据库表中的命名遵循的是不同的规范,这就需要为每个实体类做一个到数据库表名的映射。大多情况下需要映射到的表名是有一定规则的,比如我有实体类UserEntity、RoleEntity,需要将表名分别映射为T_User、T_Role,再比如mysql的表名是全小写,可以使用以下方式实现批量映射 public class MyDbContext : DbContext { public DbSet<UserEntity> Users{ get; set; } public DbSet<RoleEntity> Roles{ get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Types().Configure(t => {        //获取类名 var tableName = t.ClrType.Name;          //将类名处理为指定规范表名 tableName = "T_" + tableName.Replace("Entity",""); t

一键生成实体类 service controller等

匿名 (未验证) 提交于 2019-12-02 23:47:01
、 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><generatorConfiguration> <properties resource="ceec.dev.properties"/> <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat"> <property name="beginningDelimiter" value="`"/> <property name="endingDelimiter" value="`"/> <!--自定义模板输出插件 TemplateFilePlugin --> <!--Service interface--> <plugin type="tk.mybatis.mapper.generator.TemplateFilePlugin"> <property name="targetProject" value

SpringBoot + Mybaties的逆向工程有数据库生成domain的过程

匿名 (未验证) 提交于 2019-12-02 23:47:01
这里随便填    选择相应的Jar,如以下的勾选 下面才是最重要的操作 ,在pom.xml里面导入mybaties逆向工程需要的jar, 在pom.xml里面配置相应的所需要的代码,在这里我们单独出一个<plugle></plugle>,它跟之前的(idea自动生成的)是属于同一个评级上面. 注意这里的数据库驱动是你电脑的硬盘上的或者说是你maven的仓库里面的 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <!--利用MyBatis Generator里面的Xml文件格式,复制成为resource的xml文件,并进行修改--> <generatorConfiguration> <!--找到MySQL驱动包的路径--> <classPathEntry location="E:\maven\repository\mysql\mysql-connector-java\5.1.28\mysql-connector-java-5.1.28

建立实体类和数据库映射(注解)

匿名 (未验证) 提交于 2019-12-02 23:40:02
1.建立实体类和数据库映射 @Select("select * from user") @Results(id = "resultMap",value = { @Result(id = true,property = "userId",column ="id"), @Result(property = "userName",column ="username"), @Result(property = "userSex",column ="sex"), @Result(property = "userAddress",column ="address"), }) List<User> findAll(); 2.其他mapper对其进行引用 @Select("select * from user where id=#{id}") @ResultMap(value={"resultMap"}) User getUserById(Integer id); 文章来源: https://blog.csdn.net/qq1424035130/article/details/91446286

Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

匿名 (未验证) 提交于 2019-12-02 23:40:02
转自: https://www.cnblogs.com/crazytrip/p/5355056.html 报错信息: org.hibernate.event.internal.DefaultLoadEventListener onLoad INFO: HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.weixin.db.model.Adminusers#15] 报错分析: Hibernate的映射文件,表A里关联了表B的主键,当查询表A时,在B表里找不到对应记录时就会报错,如果只是逻辑删除不会报这种错误,只有当表B里测试没有id为15的这条数据了才会报错(已实际测试过);上面报错信息实体类后面【#15】表示实体类对应表id=15的记录找不到。也就是存在垃圾数据,可能是因为没有连带删除。 解决办法: 即: <many-to-one name="adminusers" class="com.weixin.db.model.Adminusers" fetch="select" lazy="false" not-found="ignore"> 2. 要么就把垃圾数据从数据库删掉。 补充

根据Table内容自动生成实体类

匿名 (未验证) 提交于 2019-12-02 23:03:14
一、前言 最近负责各式各样三方接口对接,从百度,阿里,腾讯,网易再到各种小三方,调三方接口难度不大,但是封装大量的参数让人不胜其烦,于是,在下一寻思,何不写个自动生成工具? 说干就干,根据阅读三方文档的经验来看,他们提供的参数信息一般是以表格形式展示,那么我的技术需求,首先的就是解析表单,接着,得到参数后,如果有合适的模版,不就可以了生成目标实体了么,vm模版,决定就是你了。 ########注意 本工具类暂时只支持docx格式生成java实体类,其他的操作,后续补充。。。。。。。。 二、环境准备 1、引入所需pom文件 <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.11</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId>