当前位置:网站首页>Idea generates entity classes from database tables
Idea generates entity classes from database tables
2022-06-28 06:00:00 【Coder without code】
original text ip:https://blog.csdn.net/crazyman2010/article/details/69668484
Configuration database
Open database settings View->Tool Windows->Database
On the right will open a Database The window of , Click on +, choice Data Source, Choose your own database type , Then fill in the parameters , You can see all the tables in your database .
Modify the script
By default , Use script generated files , There are some problems in naming , such as user_name surface , Will generate User_name.java, The same is true for the attributes inside , But if we want to generate UserName.java Words , If you modify the script .
Right click on one of the tables , choice Script Extensions->Goto Scripts Directory, The left will switch to Scratches window , open Generate POJOs.clj, Modify the following code :
(defn- java-name [name]
(apply str (map clojure.string/capitalize (re-seq #"\w+" name))))It is amended as follows
(defn- java-name [name]
; Remove it here _ Symbol , And capitalize _ The first letter after the symbol
(apply str (map clojure.string/capitalize (map #(clojure.string/replace % #"_" "") (re-seq #"[^_]+" name)))))You can also modify other things in this script , For example, remove the prefix information of the table
(defn- generate-pojo [directory table]
(let [class-name (java-name (subs (.getName table) 4)) ; Remove it here xxx_ These characters - 1
- 2
This script uses clojure Compiling , Syntax and functions can be queried here :
http://clojuredocs.org/
After modification , On related tables , The right choice Script Extensions->Generate POJOs.clj, Just save it in the pop-up window .
If you use the latest version idea, Namely idea 2018.2. Then there is no need to modify the script . It removes the underline directly .
边栏推荐
- What is the e-commerce conversion rate so abstract?
- Data middle office: an article that takes you to understand data middle office in simple terms
- 若依实现下拉框
- Working principle of es9023 audio decoding chip
- Development trend of mobile advertising: Leveraging stock and fine marketing
- [CAD drawing Video] AutoCAD 2014 master's way
- 5g network overall architecture
- Cryptography notes
- Yygh-6-wechat login
- 2022年全国职业院校技能大赛“网络安全”竞赛试题官方答案
猜你喜欢

原动力×云原生正发声 降本增效大讲堂

Capacity scheduling absolute value configuration queue usage and pit avoidance

Mysql-17- create and manage tables

Where is the era bonus for developers?

Development trend of mobile advertising: Leveraging stock and fine marketing

Apple MDM Bypass 免越狱绕过MDM配置锁 免费

Ethereum Classic的难度计算|猿创征文

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

Oracle fundamentals summary

socke.io長連接實現推送、版本控制、實時活躍用戶量統計
随机推荐
V4L2 驱动层分析
windows上安装redis并永久修改密码,及ssm框架集成redis
什么是WebRTC?
Apple MDM bypass jailfree bypass MDM configuration lock free
Differences between overloads, rewrites, abstract classes and interfaces
Independent station sellers are using the five e-mail marketing skills, do you know?
socke.io长连接实现推送、版本控制、实时活跃用户量统计
The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded
@Autowired注解为空的原因
Data center: Seven Swords of data governance
基于Kotlin+JetPack实现的MVVM框架的示例
Cryptography notes
开发者的时代红利在哪里?
Introduction to uicollectionviewdiffabledatasource and nsdiffabledatasourcesnapshot
使用SSM框架,配置多个数据库连接
JQ picture amplifier
V4l2 driver layer analysis
5GgNB和ng-eNB的主要功能
Video tutorial on website operation to achieve SEO operation [21 lectures]
Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics