В то время как моя транзакция гибернации совершается весной, я получаю ошибку ниже, может кто-нибудь помочь мне с этим - PullRequest
0 голосов
/ 14 декабря 2018

Это исключение возникает, когда моя транзакция в фиксации .. org.hibernate.internal.util.compare.ComparableComparator метод сравнения вызывается, и он дает исключение nullpointer, так как оба объекта равны нулю.Я не понимаю, почему вызывается ComparableComparator?

Класс репозитория
Это может произойти из-за некоторого обновления сущностей в цикле, но не получения фактической базовой причины.

 @Repository
@SuppressWarnings("unchecked")
public class AccountingMigrationDaoImpl implements IAccountingMigrationDao{

@Autowired
private SessionFactory sessionFactory;

@Autowired
private DozerBeanMapper mapper;

@Override
public void compairAndAddWithReservedVoucherList(Integer companyId, List<VoucherTypeMasterDto> listVoucherTypeMasterDtos) {
    List<VoucherTypeMaster> listVoucherTypeMasters = null;
    List<VoucherTypeMasterDto> rejectedReservedList = new ArrayList<VoucherTypeMasterDto>();
    List<VoucherTypeMasterDto> additionalVoucherList = new ArrayList<VoucherTypeMasterDto>();
    List<MigrationVoucherTypeMaster> listMigrationVoucherTypeMasters = new ArrayList<MigrationVoucherTypeMaster>();

    try {
        //---- Get Reserved Voucher List For updating its info against company ------//
        listVoucherTypeMasters = sessionFactory.getCurrentSession().getNamedQuery("GET_RESERVED_VOUCHER_LIST").list();
        for (VoucherTypeMasterDto voucherTypeMasterDto : listVoucherTypeMasterDtos) {

            //---- Find and update reserve voucher list given from tally voucher list -----//
            Optional<VoucherTypeMaster> matchingVoucher = listVoucherTypeMasters.stream()
                     .filter(item -> item.getReserveVoucherName().equalsIgnoreCase(voucherTypeMasterDto.getReserveVoucherName()))
                     .findFirst();
            VoucherTypeMaster voucher = matchingVoucher.orElse(null);

            if(voucher != null){
                CompanyVoucherTypeMppr comVoucherTypeMppr = mapper.map(voucherTypeMasterDto.getListCompanyVoucherTypeMpprs().get(0), CompanyVoucherTypeMppr.class,"CompanyVoucherTypeMapperMigration");

                CompanyVoucherTypeMpprId companyTypeMpprId = new CompanyVoucherTypeMpprId();
                companyTypeMpprId.setCompanyId(companyId);
                companyTypeMpprId.setVoucherTypeId(voucher.getVoucherTypeId());
                comVoucherTypeMppr.setCompanyVoucherTypeMpprId(companyTypeMpprId);

                comVoucherTypeMppr.setUseEffectiveDatesForVoucher('Y');
                comVoucherTypeMppr.setIsPrinting('N');
                comVoucherTypeMppr.setStatus('A');
                sessionFactory.getCurrentSession().update(comVoucherTypeMppr);

                MigrationVoucherTypeMaster migrationTypeMaster = new MigrationVoucherTypeMaster();
                migrationTypeMaster.setCompanyId(companyId);
                migrationTypeMaster.setvActualId(voucher.getVoucherTypeId());
                migrationTypeMaster.setvTypeName(voucherTypeMasterDto.getVoucherTypeName());

                sessionFactory.getCurrentSession().saveOrUpdate(migrationTypeMaster);

                listMigrationVoucherTypeMasters.add(migrationTypeMaster);
                //---- Ignore extra reserve voucher from tally ----//
            }else if(voucherTypeMasterDto.getReserveVoucherName() != null && !voucherTypeMasterDto.getReserveVoucherName().equalsIgnoreCase("")){
                rejectedReservedList.add(voucherTypeMasterDto);

                //---- Vouchers list except reserve and extra reserve
            }else if(voucherTypeMasterDto.getReserveVoucherName().equalsIgnoreCase("")){
                additionalVoucherList.add(voucherTypeMasterDto);
            }
        }

        for (VoucherTypeMasterDto voucherTypeMasterDto : additionalVoucherList) {
            //------- Checking extra voucher from tally which are not belongs to or childs from rejected voucher list ---//
            Optional<VoucherTypeMasterDto> matchingVoucherDto = rejectedReservedList.stream()
                     .filter(item -> item.getVoucherTypeName().equalsIgnoreCase(voucherTypeMasterDto.getParentVouhcerName()))
                     .findFirst();
            VoucherTypeMasterDto voucherDto = matchingVoucherDto.orElse(null);

            if(voucherDto == null){
                VoucherTypeMaster voucherTypeMaster = mapper.map(voucherTypeMasterDto, VoucherTypeMaster.class,"VoucherMasterDtoTOVoucherMasterMigration");

                Optional<MigrationVoucherTypeMaster> matchingVoucher = listMigrationVoucherTypeMasters.stream()
                         .filter(item -> item.getvTypeName().equalsIgnoreCase(voucherTypeMasterDto.getParentVouhcerName()))
                         .findFirst();
                MigrationVoucherTypeMaster voucher = matchingVoucher.orElse(null);

                voucherTypeMaster.setSuperVoucherTypeId(voucher.getvActualId());
                voucherTypeMaster.setCreatedBy(1);
                voucherTypeMaster.setCreatedDate(new Date().getTime());
                voucherTypeMaster.setIsPrimaryVoucher('N');
                voucherTypeMaster.setReserveVoucherName(null);

                CompanyVoucherTypeMppr companyVoucherTypeMppr = voucherTypeMaster.getListCompanyVoucherTypeMpprs().get(0);
                companyVoucherTypeMppr.setUseEffectiveDatesForVoucher('N');
                companyVoucherTypeMppr.setIsPrinting('N');
                companyVoucherTypeMppr.setStatus('Y');

                CompanyVoucherTypeMpprId companyTypeMpprId = new CompanyVoucherTypeMpprId();
                companyTypeMpprId.setCompanyId(companyId);
                companyVoucherTypeMppr.setCompanyVoucherTypeMpprId(companyTypeMpprId);
                sessionFactory.getCurrentSession().saveOrUpdate(voucherTypeMaster);

                companyTypeMpprId.setVoucherTypeId(voucherTypeMaster.getVoucherTypeId());
                sessionFactory.getCurrentSession().saveOrUpdate(companyVoucherTypeMppr);

                MigrationVoucherTypeMaster migrationTypeMaster = new MigrationVoucherTypeMaster();
                migrationTypeMaster.setCompanyId(companyId);
                migrationTypeMaster.setvActualId(voucherTypeMaster.getVoucherTypeId());
                migrationTypeMaster.setvTypeName(voucherTypeMaster.getVoucherTypeName());

                sessionFactory.getCurrentSession().saveOrUpdate(migrationTypeMaster);
                listMigrationVoucherTypeMasters.add(migrationTypeMaster);

            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}   

Трассировка стека исключений

java.lang.NullPointerException
at org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:41)
at org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:36)
at org.hibernate.type.AbstractStandardBasicType.compare(AbstractStandardBasicType.java:225)
at org.hibernate.type.ComponentType.compare(ComponentType.java:226)
at org.hibernate.action.internal.EntityAction.compareTo(EntityAction.java:171)
at org.hibernate.engine.spi.ExecutableList.add(ExecutableList.java:222)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:241)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:313)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:160)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:555)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:478)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:272)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...