myeclipse通过数据表生成jpa或hibernate实体
来源:互联网 发布:手机跑分软件 编辑:程序博客网 时间:2024/06/14 11:10
如果你已经有了数据库表,那么你又不想手工书写jpa或hibernate实体,myeclipse能够帮助你自动生成。
1、首先你需要创建一个jpa项目:
如图在普通项目上点右键添加
2、打开生成工作环境
3、创建数据库连接
因为,myeclipse也要连接数据库获取表结构
4、填写连接信息
5、打开表列表,选择导出模式
6、保存导出实体工程选择
(这一步需要第1步的操作,否则,没有可选工程)
现在就生成了entity,如:
- package com.partner4java.entity;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import static javax.persistence.GenerationType.IDENTITY;
- import javax.persistence.Id;
- import javax.persistence.Table;
- /**
- * User entity. @author MyEclipse Persistence Tools
- */
- @Entity
- @Table(name = "user", catalog = "hello_world")
- public class User implements java.io.Serializable {
- // Fields
- private Integer id;
- private String username;
- private String password;
- private String address;
- // Constructors
- /** default constructor */
- public User() {
- }
- /** minimal constructor */
- public User(String username, String password) {
- this.username = username;
- this.password = password;
- }
- /** full constructor */
- public User(String username, String password, String address) {
- this.username = username;
- this.password = password;
- this.address = address;
- }
- // Property accessors
- @Id
- @GeneratedValue(strategy = IDENTITY)
- @Column(name = "id", unique = true, nullable = false)
- public Integer getId() {
- return this.id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- @Column(name = "username", nullable = false, length = 20)
- public String getUsername() {
- return this.username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- @Column(name = "password", nullable = false, length = 20)
- public String getPassword() {
- return this.password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- @Column(name = "address", length = 20)
- public String getAddress() {
- return this.address;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- }
0 0
- myeclipse通过数据表生成jpa或hibernate实体
- myeclipse通过数据表生成jpa或hibernate实体 .
- myeclipse通过数据表生成jpa或hibernate实体
- myeclipse通过数据表生成jpa或hibernate实体
- myeclipse通过数据表生成jpa或hibernate实体
- eclipse通过数据表生成jpa或hibernate实体
- Eclipse 通过Hibernate链接数据表生成实体类
- 通过myeclipse生成实体
- MyEclipse利用自定义模板生成hibernate的dao或实体
- MyEclipse通过表生成hibernate映射文件以及实体
- myEclipse通过表生成hibernate实体和映射文件
- Myeclipse中hibernate通过数据库表反向生成实体类
- MyEclipse中hibernate通过数据库逆向生成java实体类
- myEclipse通过表生成hibernate实体和映射文件
- Eclipse 通过JPA自动生成注解实体
- Eclipse 通过JPA自动生成注解实体
- Eclipse 通过JPA自动生成注解实体
- Eclipse 通过JPA自动生成注解实体
- keytool的用法
- 去除activity上的标题
- 数据结构与算法习题汇总(3)
- QTAddMin安装失败
- 逆向随笔 - 位运算
- myeclipse通过数据表生成jpa或hibernate实体
- C++用复合梯形法求积分
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- MIME类型大全
- 构造函数
- hibernate和mybatis的比较
- Intel x86_64 Architecture Background(1)
- 走近meta
- 在DLL编程中,导出函数为什么需要extern "C"