arrays - Spring Boot,数组,JPA,数据库,角度
问题描述
是否可以使用 4 个元素的数组,例如 (int a=5; int b=6; int c=7; int d=8 ) 和 int []arr= {a,b,c,d} 并将它们放入具有不同列的表,例如:
column a column b column c column d
5 6 7 8
有人可以给我一个示例课程或给我一个相同问题的链接:
@Table(name = "columns")
int[]arr = {a,b,c,d}
@Column(name="a")
.......在此处输入代码。如何在此处使用带有元素的列。我不知道
就像是:
package com.example.demo.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="infect")
public class Infect {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@Column(name= "coordinatex")
private int coordinatex;
@Column(name= "coordinatey")
private int coordinatey;
@Column(name= "firstx")
private int firstx;
@Column(name= "firsty")
private int firsty;
public Infect(int coordinatex, int coordinatey, int firstx, int firsty) {
super();
this.coordinatex = coordinatex;
this.coordinatey = coordinatey;
this.firstx = firstx;
this.firsty = firsty;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getCoordinatex() {
return coordinatex;
}
public void setCoordinatex(int coordinatex) {
this.coordinatex = coordinatex;
}
public int getCoordinatey() {
return coordinatey;
}
public void setCoordinatey(int coordinatey) {
this.coordinatey = coordinatey;
}
public int getFirstx() {
return firstx;
}
public void setFirstx(int firstx) {
this.firstx = firstx;
}
public int getFirsty() {
return firsty;
}
public void setFirsty(int firsty) {
this.firsty = firsty;
}
}
就像如何在 arr[coordinatex,coordinatey,firstx,firsty] 中制作这个坐标,坐标,firstx,firsty,并将它们放在不像私有 int 坐标的列中,我希望它们在数组中然后在列中
解决方案
而不是这个
@Table(name = "columns")
int[]arr = {a,b,c,d}
@Column(name="a")
用这个
@Table(name = "columns")
public class Yourclass {
@Column(name="a")
public int a;
@Column(name="b")
public int b;
@Column(name="c")
public int c;
@Column(name="d")
public int d;
}
推荐阅读
- json - Azure DataFactory ForEach Copy 活动不是迭代,而是拉取 blob 中的所有文件。为什么?
- python - 将函数应用于 numpyarray 并检查每个元素以了解要返回的结果
- r - R Highcharter自定义条形图功能错误
- javascript - then() 方法如何返回值
- android - 注入 ViewModel 时出现 Dagger MissingBinding 错误
- python - 关键字必须在 ** argsPython(parser-16) 之前
- javascript - 如果生成大型数据集,Highchart 标记图像将隐藏
- openssl - 将 DER 或 PEM 中的证书转换为 pkcs12
- angular6 - 将 Angular 6 my-date-picker 模块返回的日期对象转换为日期类型
- angular - 角度反应形式:在多个formGroup中共享formControl时失去父级