idea 从数据库快速生成Spring Data JPA实体类
来源:互联网 发布:java 面试常见问题 编辑:程序博客网 时间:2024/05/21 11:25
idea 从数据库快速生成Spring Data JPA实体类
第一步,调出 Persistence 窗口.
File—>Project Structure—>model—> + —>JPA
第二步:打开 Persistence窗口
配置 生成实体类的参数
如图:
1.数据源,即链接数据库的信息,按要求填写数据库信息即可
2.生成实体类的位置.
3.实体类名称前缀.这里我什么都没写.
4.实体类名称后缀. 这里我写Entity. 比如数据库表名为 user,那么生成实体类为 UserEntity
5.选择哪些表的哪些字段生成实体类.这里我全选.
6.生成的实体类自动添加 JPA注解.
最后点击ok,就能在我们的项目下看到生成的实体类
如:
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 2017-11-25 14:02 **/@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 result; }}
阅读全文
0 0
- idea 从数据库快速生成Spring Data JPA实体类
- MyEclipse----从数据库反向生成实体类之JPA方式
- idea hibernate jpa 生成实体类
- Intellij Idea配置生成JPA实体类
- spring-data-jpa更新实体
- spring-data-jpa实体继承
- Spring Data Jpa 实体类自动创建数据库表失败解决
- spring data jpa 实体类中字段不与数据库表映射 ORA-00904 标识符无效
- Spring data jpa怎么配置一个实体类映射两张数据库表
- spring data jpa 实体类中字段不与数据库表映射
- Spring Data Jpa 实体类自动创建数据库表失败解决
- eclipse从数据库逆向生成Hibernate实体类(eclipse中反向生成hibernate实体类+jpa注释)
- eclipse从数据库逆向生成Hibernate实体类(eclipse中反向生成hibernate实体类+jpa注释)
- Eclipse从数据库逆向生成Hibernate实体类(eclipse中反向生成hibernate实体类+jpa注释)
- spring的jpa通过实体映射生成数据库中表
- 利用MyEclipse从数据库反向生成实体类之JPA方式(转载)
- 利用MyEclipse从数据库反向生成实体类之JPA方式
- 利用myeclipse从数据库反向生成实体类之JPA方式
- Android 腾讯Bugly——异常上报和应用更新
- c中动态开辟内存的几个函数
- 7XML XQuery——语法
- 使用 Spark MLlib 做 K-means 聚类分析
- 包装类DataOutputStream、DataInputStream的常见用法
- idea 从数据库快速生成Spring Data JPA实体类
- new、delete和malloc、free
- Eclipse安装SVN插件
- 代理模式
- 定义一个Language类
- Light Probe Proxy Volume component
- TCP编程
- Go语言操作mysql实现增删改查
- 区块链开发(六)本地部署 Browser-solidity