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

  • SEARCH
  • Home
  • 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 8451545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:16:13+00:00 2026-06-10T11:16:13+00:00

I’m currently developing an android application, and because i need to access a database,

  • 0

I’m currently developing an android application, and because i need to access a database, i’ve decided to use the dao pattern. Currently, i understand the concepts of this pattern.

In my app, i have my business objects. For example, let’s consider the order and the payment objects. Let’s assume that an order as a variable of the type payment. In the database, each record of the table orders will have a foreign key for the payments table, that keeps the associacion between the order and it’s payment. The problem is, as dao’s should be completely independent from each other, the OrderDao won’t “know” the PaymentDao, so how can i instantiate a order object, with the corresponding payment instance in it? This is making me really confused… The OrderDao won’t be able to return a order instance, because this instance needs a payment instance.. I could do some “tricks”, like the OrderDao returns a instance with a payment initialized with only its id, and later in the business logic, grab that id and use the PaymentDao to retrieve the payment instance and set it to the previous order… But this doesn’t sound that good..

How should this be done?

Just to make my explanation easy about the classes structure:

public class Order {
     private int id;
     private Payment payment;
     ......
}
public class Payment {
    private int id;
     ....
}

The reason i’m not using any framework, is because in my database, i need some table that hold some strings translated.. For example, if we had a categories table, i would have a categories_i18n table, that for each record in the categories table, would have the corresponding translation in some languages..

Thanks in advance.

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

    I think, You are modelling the Class Relationships wrongly in the Database. As per your requirements Your Order Class is having instance of Payment Class so when you map to the database it should be Payment that will have Order ID as the foreign key.

    Once you map it in this way. You can first get the Order from OrderDAO and then you can get Payment from PaymentDAO by using getPaymentByOrderID method. In this way your DAO will be independent and you will achieve the desired functionality.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.