Buggy code:
@ Service public class UserInternaturDetailServiceImpl implements UserInternaturDetailService { @ Autowired private UserInternaturDetailDao userInternaturDetailDao ; @ Autowired private DocumentInfoService documentInfoService ; @ Autowired private BaseService baseService ; @ Autowired private DocumentInfoDao documentInfoDao ; @ Autowired private UserRegistrationInformationService userRegistrationInformationService ; @ Override @ Transactional ( readOnly = false , propagation = Propagation . REQUIRES_NEW , rollbackFor = Exception . class ) public UserInternaturDetail saveInternaturDetails ( final UserInternaturDetail userInternaturDetail ) { } @ Override @ Transactional ( readOnly = true , propagation = Propagation . REQUIRES_NEW ) public UserInternaturDetailDto getInternatorDtoForUser ( final Long userId ) { } @ Override @ Transactional ( readOnly = false , propagation = Propagation . REQUIRES_NEW , rollbackFor = Exception . class ) public UserInternaturDetail saveInternaturdetails ( final UserInternaturDetailDto dto , final GdeUser user ) { try { UserInternaturDetail userInternaturDetail ; <START_BUG> if ( ( dto != null ) && ( ( dto . getObjId ( ) ) == 0 ) ) { <END_BUG> userInternaturDetail = userInternaturDetailDao . getUserInternatureDetail ( user . getId ( ) ) ; if ( userInternaturDetail == null ) { userInternaturDetail = new UserInternaturDetail ( ) ; } } else { userInternaturDetail = new UserInternaturDetail ( ) ; } userInternaturDetail . populateDetailFromDto ( dto , user ) ; if ( ( dto . getObjId ( ) ) == 0 ) { UserRegistrationInformation uri = userRegistrationInformationService . getUserRegistrationInformation ( user . getId ( ) ) ; if ( ( ( ( uri . getCertificateType ( ) ) == ( CertificationTypeEnum . INTERNATUR ) ) && ( ! ( GDEStringUtils . isNullOrEmpty ( dto . getCertificateInternatur ( ) . getFileName ( ) ) ) ) ) && ( ( ( dto . getCertificateInternatur ( ) . getFile ( ) ) == null ) || ( dto . getCertificateInternatur ( ) . getFile ( ) . isEmpty ( ) ) ) ) { DocumentDto docDto = fetchDefaultInternaturDoc ( user ) ; docDto . setDocCategory ( INTERNATUR ) ; dto . setCertificateInternatur ( docDto ) ; } } userInternaturDetail = userInternaturDetailDao . saveOrMerge ( userInternaturDetail ) ; dto . getCertificateInternatur ( ) . setEntityId ( userInternaturDetail . getId ( ) ) ; List < DocumentDto > documentDtoList = new ArrayList < DocumentDto > ( ) ; Collection < DocumentInfo > documentInfoList = new ArrayList < DocumentInfo > ( ) ; documentDtoList . add ( dto . getCertificateInternatur ( ) ) ; if ( ( ( dto . getInternaturFlag ( ) ) == null ) || ( ( GDEStringUtils . isNullOrEmpty ( dto . getCertificateInternatur ( ) . getFileName ( ) ) ) && ( ( ( dto . getCertificateInternatur ( ) . getFile ( ) ) == null ) || ( dto . getCertificateInternatur ( ) . getFile ( ) . isEmpty ( ) ) ) ) ) { DocumentInfo docInfo = fetchInternaturDoc ( user ) ; if ( docInfo != null ) { documentInfoService . deleteDocument ( docInfo ) ; } } else { documentInfoList = documentInfoService . saveDocumentInfo ( documentDtoList , user , userInternaturDetail , false ) ; if ( ( documentInfoList != null ) && ( ( documentInfoList . size ( ) ) > 0 ) ) { for ( DocumentInfo docInfo : documentInfoList ) { if ( ( docInfo . getCategoryName ( ) ) == ( DocCategoryEnum . INTERNATUR ) ) { dto . getCertificateInternatur ( ) . setDocId ( docInfo . getId ( ) ) ; } } } } return userInternaturDetail ; } catch ( Exception e ) { throw new GDEException ( e ) ; } } public DocumentDto fetchDefaultInternaturDoc ( final GdeUser user ) { } public DocumentInfo fetchInternaturDoc ( final GdeUser user ) { } }

Fix:
if ( ( ( dto != null ) && ( ( dto . getObjId ( ) ) != null ) ) && ( ( dto . getObjId ( ) ) == 0 ) ) {