Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:57:01+00:00 2026-06-17T08:57:01+00:00

In my application I have several persisted models and in one case I’m getting

  • 0

In my application I have several persisted models and in one case I’m getting exception when trying to get data using corresponding getter. But there is data in tha DB and I have no idea why getter returns nothing.
Answer class:

@DatabaseTable
@JsonRootName(value = "answer")
public class Answer {
    public Answer() {}        

    @DatabaseField(generatedId = true, columnName = "_id")
    @JsonIgnore
    private Integer id;

    @DatabaseField
    @JsonProperty(value = "id")
    private Integer answer_id;

    @DatabaseField(dataType = DataType.LONG_STRING)
    private String text;
    // some other fields and setters/getters
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}

Question class:

@DatabaseTable
public class Question extends BaseDaoEnabled implements Serializable {

    private static final long serialVersionUID = -7587892134579897L;

    public Question() {
    }
    @DatabaseField(foreign = true, foreignAutoRefresh = true)
    private Answer answer;
}

Quest class:

@DatabaseTable(tableName = "quests")
@JsonRootName(value = "quest")
public class Quest {

@DatabaseField(allowGeneratedIdInsert = true, generatedId = true, columnName = "_id")
private Integer id;

@DatabaseField(dataType = DataType.DATE_STRING)
Date created_at;

@DatabaseField(foreign = true)
private Survey survey;

@ForeignCollectionField(eager = false, orderColumnName = "question_id")
public Collection<Question> questions;

Answer creation:

  answer.setText(input.getText().toString());
  try {
      if (answer.getId() == null) {
          DBHelperFactory.GetHelper().getAnswersDao().create(answer);
          question.setAnswer(answer);
          DBHelperFactory.GetHelper().getQuestionsDao().update(question);
      } else  {
          DBHelperFactory.GetHelper().getAnswersDao().update(answer);
      }
      Toast.makeText(this.getActivity(), "Answer saved", 5).show();
      listener.nextQuestion();
  } catch (SQLException e) {
      Log.e(LOG_KEY, "Create failed", e);
  }

And the failing code, (quest is passed in to the function that is running in the background)

for (Question question : quest.questions) {
    if (question.getAnswer() != null) {
         Log.d(LOG_KEY, question.getId().toString());
         Log.d(LOG_KEY, question.getAnswer().getId().toString());
         Log.d(LOG_KEY, question.getAnswer().getText());
         // NullPointerException for getText().
    }
}

getAnswer() indeed returns Answer. Data in DB persisted. But getText() is failing.
Can anyone please help me to find out where I am wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:57:02+00:00Added an answer on June 17, 2026 at 8:57 am

    The key was that @DatabaseField(dataType = DataType.LONG_STRING) works strange and I couldn’t managed to make it work. After switching back to VARCHAR – problem dissappeared.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my wpf application I have several user controls, one of them is a
In my MVC application I have several submit buttons insde one form tag. How
In our SOA application we have several customers' data in the same database and
In my game application I have several different activities that all can be accessed
In my application I have several activities, the main screen has 4 buttons that
I have an application that uses AJAX liberally. I have several places where a
I have several dialogs in the application. I want to pop up help related
I have several tabs in my application, and each tab loads a different sub-page
I have several thread pools and I want my application to handle a cancel
We have several choices for logging in our .NET (C#) server application. We are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.