gpt4 book ai didi

java - JPA 正在为我的 INT 字段创建 VARCHAR 列

转载 作者:行者123 更新时间:2023-11-29 21:20:17 27 4
gpt4 key购买 nike

大家

目前,我正在尝试根据我的类规范创建一个表,但收到错误“列‘ID’的列说明符不正确”。这是因为我的 ID 字段是 VARCHAR(255) 且具有 AUTO_INCRMENT,如以下错误所示:

Error executing: CREATE TABLE gameuserstate (ID VARCHAR(255) AUTO_INCREMENT NOT NULL, ADDRESS VARCHAR(255), CITY VARCHAR(255), DOCUMENTID VARCHAR(255), FBUSERID VARCHAR(255), IDENTIFIER VARCHAR(255), LASTNAME VARCHAR(255), NAME VARCHAR(255), PASSWORD VARCHAR(255), STATE VARCHAR(255), USERSTATE LONGTEXT, USERID VARCHAR(255), ZIPCODE VARCHAR(255), PRIMARY KEY (ID))

问题是:我的类(class)的 ID 字段类型是 INT!JPA 怎么可能使用 VARCHAR(255) 字段来表示 int?

这是我的实体类:

@Table(name = "gameuserstate")
@Cacheable(false)
@Entity
public class JpaGameUserState {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private int id;

@Column
private String userid;

@PrimaryKeyJoinColumn
private JpaAccount account;

@Column
private String fbUserId;

@Column
private String identifier;

@Column
private String password;

@Column
private String name;

@Column
private String lastName;

@Column
private String documentId;

@Column
private String state;

@Column
private String city;

@Column
private String address;

@Column
private String zipcode;

// this will hold old userstate object format
@Lob
@Column
private String userState;


public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}


public String getUserid() {
return userid;
}

public void setUserid(String userid) {
this.userid = userid;
}

public JpaAccount getAccount() {
return account;
}

public void setAccount(JpaAccount account) {
this.account = account;
}

public String getFbUserId() {
return fbUserId;
}

public void setFbUserId(String fbUserId) {
this.fbUserId = fbUserId;
}

public String getIdentifier() {
return identifier;
}

public void setIdentifier(String identifier) {
this.identifier = identifier;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getDocumentId() {
return documentId;
}

public void setDocumentId(String documentId) {
this.documentId = documentId;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getZipcode() {
return zipcode;
}

public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}

public String getUserState() {
return userState;
}

public void setUserState(String userState) {
this.userState = userState;
}

}

最佳答案

你读过[所有类型的@Generated][1]

[1] http://www.objectdb.com/java/jpa/entity/generated

关于java - JPA 正在为我的 INT 字段创建 VARCHAR 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35749993/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com