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 9127023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:11:15+00:00 2026-06-17T07:11:15+00:00

as you can probably remember from my previous question about bidirectional relations in Green

  • 0

as you can probably remember from my previous question about bidirectional relations in Green DAO, I have a chat that consists of conversations and messages.
every message has a parent conversation, and the conversation has a list of messages.

when I try and add a new message, it works perfectly as long as I don’t close the application.
This is the code I use for adding a message to an existing conversation:

I now have my code that does this:

Conversation conv = getConversation();
List<Message> list = conv.getMessageList();

Message msg = new Message();
msg.setConversationId(conv,getId());
MessageDao.insert(msg);


list.add(msg);

conv.update();
// ConversationDao.update(conv);

when I open the application the next time and call conv.getMessageList(), the result is an empty ArrayList.

what am I doing wrong?

EDIT:

I changed my code and now it looks like this:

Conversation conv= getCOnversation();

Message msg = new Message();
msg.setConversation(conv);
MessageDao.insert(msg);

conv.resetMessageList();

unfortunately, now more than ever (even on same run), still calling conv.getMessageList() returns an empty java.list.

EDIT 2:

here is code for the generator (this is not the real code, but only what is important to the question.

Entity message = schema.addEntity("Message");
message.addIdProperty().autoincrement();

Entity conversation =schema.addEntity("Conversation");
conversation.addIdProperty().autoincrement();

Property parentConversation = message.addLongProperty("parentConversation")
        .getProperty();
Property messages = conversation.addLongProperty("messages").getProperty();
message.addToOne(conversation, parentConversation);
conversation.addToMany(message, messages);

EDIT 3

for now, instead of calling conv.getMessageList(); I running this line and it work fine.

List<Message> messageList = MessageDao.queryBuilder()
    .where(Properties.parentConversation.eq(conv.getId())
    .list()

I suspect a major issue for me or greenrobot in the implementation of all this.

is this an issue of running the above code while Session.runInTx?

  • 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-17T07:11:16+00:00Added an answer on June 17, 2026 at 7:11 am

    This is the problematic section:

    Property parentConversation = message.addLongProperty("parent")
        .getProperty();
    Property messages = conversation.addLongProperty("messages")
        .getProperty();
    
    message.addToOne(conversation, parentConversation);
    conversation.addToMany(message, messages);
    

    For 1:N relations, you must use the same property for both your ToOne and ToMany relation. Try this and regenerate your code:

    Property parentConversation = message.addLongProperty("parent")
        .getProperty();
    message.addToOne(conversation, parentConversation);
    conversation.addToMany(message, parentConversation);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the question you can probably tell that I don't know much about code!
This is probably a stupid question but I can not seem to either remember
Probably for someones this question is trivial but i can't remember which is the
This is probably quite a simple question, but I can't remember how to do
I am aware that you can probably build a lower version of .NET, but
I've hacked together some php code that can probably be improved in terms of
From what I remember from my C++ class, the professor said that operator overloading
Ok. Googling fail probably and I remember reading about this a while back but
Sorry for posting something that's probably obvious, but I don't have much database experience.
I can't, for the life of me, remember what exactly our teacher said that

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.