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());
}
Similar Posts:
- [Solved] org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected1, actual0
- [Solved] Error creating bean with name ‘transactionManager’ defined in class path resource [spring-dao.xml]
- [Solved] Mybatis error: attempted to return null from a method with a primitive return type (int)
- hibernate java.lang.StackOverflowError: null
- Several cases of error reporting in java.lang.nullpointerexception
- How to Solve Struts2 Error: java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
- There is no PasswordEncoder mapped for the id “null” [How to Solve]
- [Solved] Spring Boot Error: “jdbcUrl is required with driverClassName.”
- [Solved] JS Ajax uploads an error “uncaught type error: illegal invocation”
- [How to Solve] Exception starting filter struts2