当前位置:网站首页>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 .
边栏推荐
- Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:异常解决
- File foundation - read / write, storage
- 脚本语言和编程语言
- Global country (and region) information JSON data
- socke.io长连接实现推送、版本控制、实时活跃用户量统计
- Filecoin黑客松开发者大赛
- Data center: Seven Swords of data governance
- lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
- What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
- Flink window mechanism (two waits and the last explanation)
猜你喜欢

Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes

Mysql-16-subquery

6. graduation design temperature and humidity monitoring system (esp8266 + DHT11 +oled real-time upload temperature and humidity data to the public network server and display the real-time temperature

Jenkins继续集成2

Development trend of mobile advertising: Leveraging stock and fine marketing

Capacity scheduling absolute value configuration queue usage and pit avoidance

JSP

What is webrtc?

mac下安装多个版本php并且进行管理

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
随机推荐
Global country (and region) information JSON data
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:异常解决
Shanghai Yuge ASR CAT1 4G module 2-way low power 4G application
若依实现下拉框
ipvs 导致syn 重传问题
sql及list去重操作
[MySQL] all query tables contain 20million data -- how to optimize SQL
Apple MDM bypass jailfree bypass MDM configuration lock free
移动广告发展动向:撬动存量,精细营销
5g network overall architecture
Typescript interface
Mosaic data enhanced mosaic
qtcanpool 知 07:Ribbon
Cryptography notes
YYGH-8-预约挂号
19 fonctions de perte d'apprentissage profond
Qtcanpool q05: no border
death_satan/hyperf-validate
YYGH-6-微信登录
The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded