将SQL表转换为java bean类 [英] convert SQL table to java bean class

查看:143
本文介绍了将SQL表转换为java bean类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用大量SQL表在Web应用程序中工作。我需要为每个表创建一个java bean类。我正在寻找一种可以将SQL表转换为java bean类的工具。这将有助于节省时间。

I'm working in web application using a huge number of SQL tables. I need to create for each table a java bean class. I'm searching for a tool that can convert SQL table to a java bean class. It will help to save time.

以下是一个示例:

studentTable(studentId,firstname,lastname,年级)

studentTable (studentId, firstname, lastname, yearLevel)

-->

public class Student {
    @Id
    @Column
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int studentId;
    @Column
    private String firstname;
    @Column
    private String lastname;
    @Column
    private int yearLevel;

    public Student(){}
    public Student(int studentId, String firstname, String lastname,
            int yearLevel) {
        super();
        this.studentId = studentId;
        this.firstname = firstname;
        this.lastname = lastname;
        this.yearLevel = yearLevel;
    }
    public int getStudentId() {
        return studentId;
    }
    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }
    public String getFirstname() {
        return firstname;
    }
    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }
    public String getLastname() {
        return lastname;
    }
    public void setLastname(String lastname) {
        this.lastname = lastname;
    }
    public int getYearLevel() {
        return yearLevel;
    }
    public void setYearLevel(int yearLevel) {
        this.yearLevel = yearLevel;
    }
}

您对此类工具有任何了解吗。

Do you have any idea about such tool.

推荐答案

使用Hibernate。

Use Hibernate.

它允许您生成模型类您的数据库表。

It allows you to generate model-classes for your database tables.

调用函数: Hibernate映射文件和数据库中的POJO',也使用 Hibernate逆向工程向导

The "function" is called: Hibernate mapping files and POJO'S from database, also use Hibernate Reverse Engineering Wizard.

我使用Netbeans和Hibernate生成所有这些模型。

I use Netbeans and Hibernate to generate all these models.

这篇关于将SQL表转换为java bean类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆