Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在spring数据中使用hibernate存储对象列表_Java_Spring_Hibernate - Fatal编程技术网

Java 在spring数据中使用hibernate存储对象列表

Java 在spring数据中使用hibernate存储对象列表,java,spring,hibernate,Java,Spring,Hibernate,我需要在spring数据中使用hibernate在db中存储一个对象列表。基本上,我需要将列表存储在与数据库的单个交互中 为此,我尝试如下: //a part of my code: if(vacationAirTravellerLegInfoList.size() != 0) { customVacationAirTravellerLegInfoRepository.save(vacationAirTravellerLegInfoList); } 对于上述部分,

我需要在spring数据中使用hibernate在db中存储一个对象列表。基本上,我需要将列表存储在与数据库的单个交互中

为此,我尝试如下:

//a part of my code:
if(vacationAirTravellerLegInfoList.size() != 0) {   
            customVacationAirTravellerLegInfoRepository.save(vacationAirTravellerLegInfoList);
}
对于上述部分,“customVacationAirTravellerLegInfoRepository”是我试图实现的自定义存储库的对象,具体如下:

@Repository
public interface CustomVacationAirTravellerLegInfoRepository extends VacationAirTravellerLegInfoRepository, CrudRepository<VacationAirTravellerLegInfo, Integer> {
    List<VacationAirTravellerLegInfo> save(List<VacationAirTravellerLegInfo> airTravellerLegInfoList);

}

任何人请建议或纠正我。

您可能需要转换列表元素

VacationAirTravellerLegInfo vacationAirTravellerLegInfo =  (VacationAirTravellerLegInfo) airTravellerLegInfoList.get(i);

事实上,我甚至无法在save方法中获得控制权。我根据给定的异常进行了假设,该异常表示“spring数据试图在ArrayList中找到“id”属性。”
{
    "timestamp": 1529303873662,
    "status": 500,
    "error": "Internal Server Error",
    "exception": "org.springframework.beans.NotReadablePropertyException",
    "message": "Invalid property 'id' of bean class [java.util.ArrayList]: Could not find field for property during fallback access!",
    "path": "/api/server/vacation/save"
}
VacationAirTravellerLegInfo vacationAirTravellerLegInfo =  (VacationAirTravellerLegInfo) airTravellerLegInfoList.get(i);