Spring Data JPA,使用参数String []

时间:2015-06-23 03:58:34

标签: java spring hibernate spring-mvc jpa

我正在尝试使用Spring-Data-JPA和Spring-boot。我有问题如何使用带有参数String []数组的Spring-Data-JPA保存或插入到数据库中。 这是我的表的例子:

表A => ID | col_0 | COL_1 | COL_2 | col_4 | col_5 | col_6 | col_7 | col_8 | col_9 | col_10

我有一个我从解析文件中得到的数组(不同的文件 - 不同长度的数组,不大于表A Col_)

TableA类:

public class TableA implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@Column(name = "col_0")
private String col0;

@Column(name = "col_1")
private String col1;

@Column(name = "col_2")
private String col2;

@Column(name = "col_3")
private String col3;

@Column(name = "col_4")
private String col4;

@Column(name = "col_5")
private String col5;

@Column(name = "col_6")
private String col6;

@Column(name = "col_7")
private String col7;

@Column(name = "col_8")
private String col8;

@Column(name = "col_9")
private String col9;

@Column(name = "col_10")
private String col10;

/*Setter Getter*/

问题是如何使用Spring Data JPA将Array保存或插入表A的最简单方法。 例如,我有file1有5个索引,File2有8个索引。

示例:

String[] file1 = file.split(".");
String[] result = new String[Constant.MAX_ROW_OF_TABLE_A]; //12

for (int i = 0; i < file1.length; i++){
   result[i] = file1[i];
}

tableARepository.insertIntoDatabase(result); //How the method to insert ?

这是我的全部问题,我希望我能找到答案。谢谢:)

0 个答案:

没有答案