Project

General

Profile

bug #9483

LazyInitializationException (LIE) in TaxonNamePopupEditor when selecting trinominal rank

Added by Andreas Kohlbecker about 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Highest
Category:
cdm-vaadin
Target version:
Start date:
02/26/2021
Due date:
% Done:

100%

Severity:
normal
Found in Version:
Tags:

Description

The LIE occurs in public String rankSpecificNamePart() at rank.isHigher(Rank.GENUS()) which internally calls OrderedTermBase.performCompareTo(T thatTerm, boolean skipVocabularyCheck) where the vocabulary is required for comparison.
The rank.vocabulary is not initialized in the case covered by this ticket.


Related issues

Copied to Edit - task #9490: avoid rank entity in TaxonNameParts Resolved 02/26/2021

Associated revisions

Revision e20135dc (diff)
Added by Andreas Kohlbecker about 2 months ago

fix #9483 adapting bean initialization in .TaxonNameDaoHibernateImpl.prepareFindTaxonNameParts(..) to new? rank compare

Revision d10e9a39 (diff)
Added by Andreas Kohlbecker about 1 month ago

fix #9483 initializing rank.vocabulary in the TaxonNameParts constructor

Revision a05e4acf (diff)
Added by Andreas Kohlbecker about 1 month ago

fix #9483 initializing rank.vocabulary in the TaxonNameParts constructor - comment

Revision 6d804466 (diff)
Added by Andreas Kohlbecker about 1 month ago

fix #9483 better solution by using rankClass only

Revision 520afc6d (diff)
Added by Andreas Kohlbecker about 1 month ago

fix #9483 better solution by using rankClass only - restoring chanches after merge with previous cleanup

History

#1 Updated by Andreas Kohlbecker about 2 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50

#2 Updated by Andreas Kohlbecker about 2 months ago

  • Assignee changed from Andreas Kohlbecker to Wolf-Henning Kusber

please review

#3 Updated by Wolf-Henning Kusber about 2 months ago

  • Assignee changed from Wolf-Henning Kusber to Andreas Kohlbecker

Review: Internal error when selecting variety of form, instead of opening a third field for the last epithet.

#4 Updated by Andreas Kohlbecker about 1 month ago

Usually we are passing initStrategies to the service methods in order to initialize associated entities. In this case this way would not be appropriate since the method causing the LIE is member method of the Class which is being used in a select new {constructor} expression.
Therefore the proper most solution for this problem would be to initialize the rank.vocabulary directly in the TaxonNameDaoHibernateImpl.
This however is not (yet?) working due to a specific interpretation of the JPA language specs: https://hibernate.atlassian.net/browse/HHH-3345 so the following code will not work:

private StringBuilder prepareFindTaxonNameParts(boolean doCount, Optional<String> genusOrUninomial,
            Optional<String> infraGenericEpithet, Optional<String> specificEpithet,
            Optional<String> infraSpecificEpithet, Rank rank, Collection<UUID> excludedNamesUuids) {

        StringBuilder hql = new StringBuilder();
        if(doCount){
            hql.append("select count(n.id) ");
        } else {
            hql.append("select new eu.etaxonomy.cdm.persistence.dto.TaxonNameParts(n.id, n.uuid, n.rank, n.genusOrUninomial, n.infraGenericEpithet, n.specificEpithet, n.infraSpecificEpithet) ");
        }
        hql.append("from TaxonName n ");
        if(!doCount){
            // >>>>>>>>>>>>>> need to initialize the ranks with vocabulary to avoid LIEs in TaxonNameParts.rankSpecificNamePart() see #9483
            // >>>>>>>>>>>>>> This will not work due to HHH-3345 
            hql.append("left join fetch n.rank as r left join fetch r.vocabulary as v ");
        }
        hql.append("where 1 = 1 ");

        if(rank != null){
            hql.append("and n.rank = :rank ");
        }
        if(excludedNamesUuids != null && excludedNamesUuids.size() > 0){
            hql.append("and n.uuid not in ( :excludedNamesUuids ) ");
        }

        addFieldPredicate(hql, "n.genusOrUninomial", genusOrUninomial);
        addFieldPredicate(hql, "n.infraGenericEpithet", infraGenericEpithet);
        addFieldPredicate(hql, "n.specificEpithet", specificEpithet);
        addFieldPredicate(hql, "n.infraSpecificEpithet", infraSpecificEpithet);

        return hql;
    }

Therefore I decided to initialize the rank.vocabulary in the constructor:

    public TaxonNameParts(Integer taxonNameId, UUID taxonNameUuid, Rank rank, String genusOrUninomial, String infraGenericEpithet,
            String specificEpithet, String infraSpecificEpithet) {
        super();
        this.taxonNameId = taxonNameId;
        this.taxonNameUuid = taxonNameUuid;
        this.rank = rank;
        if(rank != null) {
            HibernateBeanInitializer.initialize(rank.getVocabulary());
        }
        this.genusOrUninomial = genusOrUninomial;
        this.infraGenericEpithet = infraGenericEpithet;
        this.specificEpithet = specificEpithet;
        this.infraSpecificEpithet = infraSpecificEpithet;
    }

#5 Updated by Andreas Kohlbecker about 1 month ago

  • Assignee changed from Andreas Kohlbecker to Wolf-Henning Kusber

Hi Henning, this issue can be reviewed again.

#6 Updated by Andreas Kohlbecker about 1 month ago

  • Description updated (diff)

#7 Updated by Andreas Kohlbecker about 1 month ago

  • Copied to task #9490: avoid rank entity in TaxonNameParts added

#8 Updated by Andreas Kohlbecker about 1 month ago

new ticket for possibly better solution #9490

#9 Updated by Wolf-Henning Kusber about 1 month ago

  • Assignee changed from Wolf-Henning Kusber to Andreas Kohlbecker
  • % Done changed from 50 to 100

Trinominals can be created and stored. If this is due to 9483 this ticket can be closed.

#10 Updated by Andreas Kohlbecker about 1 month ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)