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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:08:11+00:00 2026-06-04T12:08:11+00:00

I have just started to read about ORMLite so I am still a beginner.

  • 0

I have just started to read about ORMLite so I am still a beginner.
As far as I understand I can query objects using any of their persistent attributes.

For example, if I have the following classes:

@DatabaseTable
public class Bill {
  @DatabaseField String code;
  Client client; 
  List<Item> items;
}

@DatabaseTable
class Client {
  @DatabaseField String name;
}

@DatabaseTable
class Item {
  @DatabaseField String name;
}

(not sure how to annotate the client and items attributes in the class Bill).

In any case, a query like this will help me to obtain all the Bill objects with a particular code number:

QueryBuilder<Bill, String> queryBuilder = BillDao.queryBuilder();
Where<Bill, String> where = queryBuilder.where();
where.eq(BILL.NAME_CODE, "abc123");
PreparedQuery<Account> preparedQuery = queryBuilder.prepare();

My question is: what is the recommended way in ORMLite to write queries that have conditions in transitive relations of my model object ? for example “All the bills that include a particular item with a certain name”? or “All the clients that have bought an item with a certain name” ?.

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-04T12:08:13+00:00Added an answer on June 4, 2026 at 12:08 pm

    Read Foreign Object Fields and Foreign Collections in ormLite docs.

    Your relationship will be:

    @DatabaseTable(tableName = "bills")
    public class Bill {
        public static final String ACCOUNT_ID_FIELD_NAME = "client_id";
        @DatabaseField(generatedId = true)
        private int id;
        @DatabaseField(foreign = true, columnName = ACCOUNT_ID_FIELD_NAME)
        private Client client;
        @DatabaseField 
        private String code;
        Client client; 
        List<Item> items;
    
        public Bill(){
    
        }
        public Bill(Client client, String code){
            this.client = client;
            this.code = code;
        }
    
        public int getId(){
            return this.id;
        }
        public String getCode(){
            return this.code;
        }
    }
    
    @DatabaseTable(tableName = "clients")
    class Client {
        public static final String NAME_FIELD_NAME = "name";
        public Client() {
            // all persisted classes must define a no-arg constructor with at least package visibility
        }
        public Client(String name) {
            this.name = name;
        }
        @DatabaseField(generatedId = true)
        private int id;
        @DatabaseField(columnName = NAME_FIELD_NAME, canBeNull = false) 
        private String name;
    
        public int getId(){
            return this.id;
        }
        public String getName(){
            return this.name;
        }
    }
    

    More information can be found in the code examples.

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

Sidebar

Related Questions

i have just started using Moq ver (3.1) and i have read blogs and
I just started to read about this new technology... Does someone have some knowledge
I Have just started with django-rest-framework. Pretty enthousiastic about it, except for the fact
I have been looking at using TDD and implementing proper testing (only just started
I have just started considering using the HTML 5 api for a Rails/JQuery project,
I have just started learning about socket programming and learned about winsock and achieved
I have just started developing a full-web application by using the ASP .NET MVC
I have just started reading Modern C++ Design Generic programming and Design Patterns Applied
i have just started playing aorund with asp.net mvc and i want to view
We have just started out with Team Foundation Server 2008 / Visual Studio Team

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.