In my Spring Boot Project I have two classes (Entity and Model)
In the model there is a List<List<Object>>:
public class FCSeriesModel {
private String name;
private List<List<Object>> values;
//GET & SET
}
In the entity there is a List<List<String>>
(because I can't use a List<List<Object>>):
@Entity
@Table(name = "Final_Feign_Client_Result")
public class FinalFCResultEntity {
@Id
@Column(name = "id")
@GeneratedValue(strategy = IDENTITY)
private Integer id;
@Column(name = "name")
private String name;
@ElementCollection
@CollectionTable(name = "Final_Feign_Client_Result_Columns")
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "final_feign_client_result_entity_id", nullable = false)
protected List<List<String>> values;
// GET & SET
}
How to convert the
List<List<Object>> to
List<List<String>>
in a method of a service class to post the values of the model in the db?
@Transactional
public FinalFCResultEntity postFinalFCResultEntity() throws Exception {
final String methodName = "getAllMonterotondoMarittimoModelPstgrs()";
try {
this.startLog(methodName);
String token = getToken();
FinalFCResultModel FFCRM = feignClient.getAllObject(token);
logger.info("Request Successful");
logger.info("FeignClientResultModel:" + FFCRM.toString());
List<FCResultModel> FCRMs = FFCRM.getResults();
FinalFCResultEntity FFCRE = new FinalFCResultEntity();
if (!FCRMs.isEmpty()) {
for (FCResultModel currFCRM : FCRMs) {
for (FCSeriesModel currFCSM : currFCRM.getSeries()) {
FFCRE.setName(currFCSM.getName());
//ADD setting FFCRE values?????
FinalFCResultEntity FFCREsaved = finalFCResultDao.save(FFCRE);
}
}
}
this.endLog(methodName, FFCRE);
return FFCRE;
} catch (final Exception e) {
logger.error(e.getMessage());
this.errorLog(methodName, e);
throw e;
}
}