本篇內(nèi)容主要講解“idea怎么從數(shù)據(jù)庫(kù)快速生成Spring Data JPA實(shí)體類”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“idea怎么從數(shù)據(jù)庫(kù)快速生成Spring Data JPA實(shí)體類”吧!
成都創(chuàng)新互聯(lián)公司是一家專業(yè)提供蓬溪企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、HTML5、小程序制作等業(yè)務(wù)。10年已為蓬溪眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。
File—>Project Structure—>model—> + —>JPA
1.數(shù)據(jù)源,即鏈接數(shù)據(jù)庫(kù)的信息,按要求填寫數(shù)據(jù)庫(kù)信息即可
2.生成實(shí)體類的位置.
3.實(shí)體類名稱前綴.這里我什么都沒寫.
4.實(shí)體類名稱后綴. 這里我寫Entity. 比如數(shù)據(jù)庫(kù)表名為 user,那么生成實(shí)體類為 UserEntity
5.選擇哪些表的哪些字段生成實(shí)體類.這里我全選.
6.生成的實(shí)體類自動(dòng)添加 JPA注解.
如:
package com.itguang.weixinsell.entity; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.sql.Timestamp; /** * @author itguang * @create @Entity @Table(name = "product_category", schema = "sell", catalog = "") public class ProductCategoryEntity private int categoryId; private String categoryName; private int categoryType; private Timestamp createTime; private Timestamp updateTime; @Id @Column(name = "category_id") public int getCategoryId() { return categoryId; } public void setCategoryId(int categoryId) { this.categoryId = categoryId; } @Basic @Column(name = "category_name") public String getCategoryName() { return categoryName; } public void setCategoryName(String categoryName) { this.categoryName = categoryName; } @Basic @Column(name = "category_type") public int getCategoryType() { return categoryType; } public void setCategoryType(int categoryType) { this.categoryType = categoryType; } @Basic @Column(name = "create_time") public Timestamp getCreateTime() { return createTime; } public void setCreateTime(Timestamp createTime) { this.createTime = createTime; } @Basic @Column(name = "update_time") public Timestamp getUpdateTime() { return updateTime; } public void setUpdateTime(Timestamp updateTime) { this.updateTime = updateTime; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ProductCategoryEntity that = (ProductCategoryEntity) o; if (categoryId != that.categoryId) return false; if (categoryType != that.categoryType) return false; if (categoryName != null ? !categoryName.equals(that.categoryName) : that.categoryName != null) return false; if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false; if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) return false; return true; } @Override public int hashCode() { int result = categoryId; result = 31 * result + (categoryName != null ? categoryName.hashCode() : 0); result = 31 * result + categoryType; result = 31 * result + (createTime != null ? createTime.hashCode() : 0); result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0); return
到此,相信大家對(duì)“idea怎么從數(shù)據(jù)庫(kù)快速生成Spring Data JPA實(shí)體類”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
網(wǎng)頁(yè)題目:idea怎么從數(shù)據(jù)庫(kù)快速生成SpringDataJPA實(shí)體類
標(biāo)題鏈接:http://muchs.cn/article48/ijsgep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、外貿(mào)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、小程序開發(fā)、虛擬主機(jī)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)