当前位置:网站首页>idea根据数据库表生成实体类
idea根据数据库表生成实体类
2022-06-28 05:55:00 【不会code的coder】
原文ip:https://blog.csdn.net/crazyman2010/article/details/69668484
配置数据库
打开数据库设置View->Tool Windows->Database
在右侧会打开一个Database的窗口,点击+,选择Data Source,选择自己的数据库类型,然后填写好参数,就可以看到自己数据库中所有的表了。
修改脚本
默认的情况下,使用脚本生成的文件,在命名上有些问题,比如 user_name表,会生成User_name.java,里面的属性也是这样的,但如果我们希望生成UserName.java的话,如果修改脚本。
在其中一个表上右键,选择Script Extensions->Goto Scripts Directory,左侧会切换到Scratches窗口,打开Generate POJOs.clj,修改如下一段代码:
(defn- java-name [name]
(apply str (map clojure.string/capitalize (re-seq #"\w+" name))))修改为
(defn- java-name [name]
;这里去除_符号,并大写_符号后的第一个字母
(apply str (map clojure.string/capitalize (map #(clojure.string/replace % #"_" "") (re-seq #"[^_]+" name)))))同时也可以修改这个脚本里面的其他东西,比如去除表的前缀信息
(defn- generate-pojo [directory table]
(let [class-name (java-name (subs (.getName table) 4)) ;这里去除xxx_这几个字符- 1
- 2
这个脚本是使用clojure编写的,语法和函数可以到这里查询:
http://clojuredocs.org/
修改好之后,在相关的表上面,右键选择Script Extensions->Generate POJOs.clj,在弹出的窗口中保存就可以了。
如果使用的是最新版的idea,就是idea 2018.2.那就不用修改脚本。它直接去除下划线。
边栏推荐
- 函数栈帧的创建和销毁
- 使用SQL select count distinct查询语句统计数据库中某个字段的唯一值总数量
- Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
- Typescript interface
- File foundation - read / write, storage
- [MySQL] all query tables contain 20million data -- how to optimize SQL
- Application of Beidou No.3 short message terminal in dam safety monitoring scheme
- 自定义 cube-ui 弹出框dialog支持多个且多种类型的input框
- Prime mover × Cloud primordial is making sound, reducing cost and increasing efficiency lecture hall
- Xcode13.3.1 项目执行pod install后报错
猜你喜欢

ES9023音频解码芯片的工作原理

上海域格ASR CAT1 4g模块2路保活低功耗4G应用

6. 毕业设计温湿度监控系统(ESP8266 + DHT11 +OLED 实时上传温湿度数据给公网服务器并在OLED显示屏上显示实时温湿度)

Mysql-16-subquery

Jenkins continuous integration 1
![RL practice (0) - and the platform xinchou winter season [rule based policy]](/img/dc/10d615c64123475fea180e035095ff.png)
RL practice (0) - and the platform xinchou winter season [rule based policy]

Capacity scheduling absolute value configuration queue usage and pit avoidance

File foundation - read / write, storage

5G网络整体架构

Valueerror: iterative over raw text documents expected, string object received
随机推荐
pytorch详解
Mysql-16-subquery
从0配置redis
sklearn 特征工程(总结)
数据中台:一篇带你深入浅出了解数据中台
How to do a good job of dam safety monitoring
Data middle office: six questions data middle office
原动力×云原生正发声 降本增效大讲堂
Application of Beidou No.3 short message terminal in dam safety monitoring scheme
一看就会 MotionLayout使用的几种方式
数据中台:AI中台的实施与总结
小球弹弹乐
Oracle fundamentals summary
Ethereum Classic的难度计算|猿创征文
Valueerror: iterative over raw text documents expected, string object received
Using pytorch and tensorflow to calculate the confusion matrix of classification model
Bidirectional level conversion circuit
Academic search related papers
Error: the following arguments are required:
MR-WordCount