java.lang.IllegalArgumentException: id to load is required for loading
Error:
First of all, the reason for this error: when using hibernate, we sometimes encounter this exception: Java. Lang. illegalargumentexception: ID to load is required for loading. This is because when using a query like findbyid (ID), the passed in ID is null
First of all, we should check the specific error code, and run debug to see where the data is not found
Take my following code as an example:
public boolean formdataspecExist(QmFormData formdata) throws FrameExecuteException {
List<QmFormData> queryForList = null;
//Determine if the specific id value to be passed is not empty
if(formdata.getPlanworkres().getCod() !=null && StringUtils.isNotEmpty(formdata.getPlanworkres().getCod())&&StringUtils.isNotEmpty(formdata.getPlant().getCod())&&formdata.getPlant().getCod()!=null) {
//Spell your own hql statements
queryStruct.clear().contactHql("From QmFormData f where typ=6 ");
queryStruct.contactHql("and f.plant.cod=:PlantCod").addParam("PlantCod", formdata.getPlant().getCod());
queryStruct.contactHql("and f.planworkres.cod like '%"+formdata.getPlanworkres().getCod().trim()+"%'");
queryForList= baseDao.query(queryStruct.getHql(), queryStruct.getQueryParams());
}