#Error: no value present

4 messages · Page 1 of 1 (latest)

fringe hill
#

Hello, I get the error "no value present" when I try to return a created object with filled attributes.
I did search already for help to this issue, but most of the results are facing the problem of array objects, what doesn't fit here.
When I add more then a Id to my object the error occurs.
Code below.

fallen anchorBOT
#

This post has been reserved for your question.

Hey @fringe hill! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

fringe hill
#
public static Possession getPossessionById(int iPosId) {
        try {       
            Database db = new Database();

            Dao<DBPossession, Integer> dao = db.Init(DBPossession.class);

            QueryBuilder<DBPossession, Integer> queryBuilder = dao.queryBuilder();
            queryBuilder.where().eq(DBPossession.ID_FIELD_NAME, iPosId);
            PreparedQuery<DBPossession> preparedQuery = queryBuilder.prepare();
            DBPossession dbPossession = dao.queryForFirst(preparedQuery);
            
            db.Close();
            
            if (dbPossession != null) {
                Possession oPos = new Possession();
                LingoPropertyMap oLPM = new LingoPropertyMap();
                
                oPos.setAquiredOn(dbPossession.getAcquiredOn());
                oPos.setDatePurchased(dbPossession.getDatePurchased());
                oPos.setCatalogItem(dbPossession.getCatalogItem());
                oPos.setFacingDirection(dbPossession.getFacingDirection());
                oPos.setID(dbPossession.getId());
                oPos.setOwnerScreenName(dbPossession.getOwnerScreenName());
                oPos.setPlacedIn(dbPossession.getPlacedIn());
                oPos.setPropertiesString(dbPossession.getProperties());
                oLPM.setproperties(dbPossession.getProperties());
                oPos.setProperties(oLPM);
                oPos.setPurchasePrice(dbPossession.getPurchasePrice());
                oPos.setState(dbPossession.getState());
                oPos.setXPos(dbPossession.getXPos());
                oPos.setYPos(dbPossession.getYPos());
                oPos.setZPos(dbPossession.getZPos());
                
                return oPos;
            } else {
                return null;
            }
        } catch (Exception e) {
            System.out.println("Exception (getPossessionById): " + e.getMessage());
        }
        
        return null;
    }