对于我的pojo类表,没有在数据库中创建

时间:2018-05-23 12:54:13

标签: java

以下pojo类表未创建

RegistrationBean.java

package com.cg.uas.beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "registration")
public class RegistrationBean {

    @Column(name = "firstName")
    private String firstName;

    @Column(name = "lastName")
    private String lastName;


    @Column(name = "userEmail")
    private String userEmail;
    @Column(name = "address")
    private String address;
    @Column(name = "contactNo")
    private long contactNo;

    @Column(name = "userPassword")
    private String userPassword;
    //getters and setters 
}

如果我为上述任何pojo类成员添加@Id注释,则表正在创建表。

1 个答案:

答案 0 :(得分:0)

试试这个..

package com.cg.uas.beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "registration")
public class RegistrationBean {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "regId")
    private long regId;

    @Column(name = "firstName")
    private String firstName;

    @Column(name = "lastName")
    private String lastName;


    @Column(name = "userEmail")
    private String userEmail;
    @Column(name = "address")
    private String address;
    @Column(name = "contactNo")
    private long contactNo;

    @Column(name = "userPassword")
    private String userPassword;
    //getters and setters 
}