Hibernate encountered an error in executing hql statement

this is to get List < PortfolioMemberView > at the Dao layer, and I am in the

public List<PortfolioMemberView> getPortfolioMemberViewByPid(Integer pid){
        //portfolioId 
        System.out.print(pid);
        try {
            Session session = sessionFactory.getCurrentSession();
            String sql = "from PortfolioMemberView pv where pv.portfolioId = ?0";
            Query query = session.createQuery(sql).setParameter(0, pid);
            List<PortfolioMemberView> pmvl = query.list();
            //printconsole
            for(PortfolioMemberView pv: pmvl){
                System.out.print(pv.getAssetCode());
            }
            return pmvl;
        }catch(Exception e){
            logger.info(":"  + e.getMessage() + ", " +e.getCause());
            throw new RuntimeException();
        }
        
}

at this point I have the following data in the PortfolioMemberView view of the database,

portfolioId    assetId    accountType    assetCode    assetLabel    value_    annualReturn    returnRate
10    1    S    wOOWoo1S    Canadian National    8699.75    1379.1885    0.15853196930946292
15    1    S    wOOWoo1S    Canadian National    782    123.97200000000001    0.15853196930946292
13    1    S    wOOWoo1S    Canadian National    0    0    
11    1    S    wOOWoo1S    Canadian National    879.75    139.4685    0.15853196930946292
5    2    P    CMPROP0121    Commercial Property    1.04    56960.05564    54769.28426923077
2    2    P    CMPROP0121    Commercial Property    101.92    5582085.45272    54769.284269230775
2    4    P    kckb    karawokie    630    484097.4    768.4085714285715
2    5    S    GYck    ClickGym    4806    375580    78.14814814814815
10    5    S    GYck    ClickGym    4860    379800    78.14814814814815
13    5    S    GYck    ClickGym    486    37980    78.14814814814815
14    5    S    GYck    ClickGym    4860    379800    78.14814814814815
2    8    S    min7b    sd    7182    68731.74    9.57
2    9    D    heyBo    saveBow    9    171.76983230868902    19.085536923187668

the output from console to me when the method is triggered is like this,

2
Hibernate: select portfoliom0_.portfolioId as portfoli1_8_, portfoliom0_.assetId as assetId2_8_, portfoliom0_.accountType as accountT3_8_, portfoliom0_.assetCode as assetCod4_8_, portfoliom0_.assetLabel as assetLab5_8_, portfoliom0_.value_ as value_6_8_, portfoliom0_.annualReturn as annualRe7_8_, portfoliom0_.returnRate as returnRa8_8_ from PortfolioMemberView portfoliom0_ where portfoliom0_.portfolioId=?
CMPROP0121CMPROP0121CMPROP0121CMPROP0121CMPROP0121

I don"t quite understand that when portfolioId is 2, the asseCode attribute of the corresponding three records should be CMPROP0121,kckb,GYck,
, but the result is missing three CMPROP0121 in a row. I can"t see where this bug is caused. Hibernate printed the generated sql statement in console. I ran to the database and the output was correct. However, the list results obtained by this method are not correct.
ask God for help.

Dec.13,2021

did you turn portfolioId map into id? This is the caching mechanism of hibernate. It takes the first row and caches it according to id. When taking the second row, if the id is the same, hibernate will think they are the same, and will directly extract the output from the cache.

if there are duplicates in portfolioId, do not map into id.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8eb34-11f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8eb34-11f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?