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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:23:12+00:00 2026-05-27T16:23:12+00:00

I just started using OrmLite so I am playing around with it. I have

  • 0

I just started using OrmLite so I am playing around with it. I have trouble understanding a few concepts, esp. dealing with many to many relationships.

These are my main tables:

Pc
    Name
    Domain
Ethernet
    IP
    Gateway
    Subnet
    MAC

And here the ones ensuring many-to-many-relationship just as in the online-example:

PcEth

I populate the Database via:

    PC somePc = new PC("randomPc", "someDomain");
    pcDao.create(somePc);

    Ethernet eth1 = new Ethernet("127.255.0.1", "255.0.0.0", "192.168.1.1", "macadress");
    Ethernet eth2 = new Ethernet("192.168.1.1", "255.0.0.0", "192.168.1.1", "macadress");
    ethernetDao.create(eth1);
    ethernetDao.create(eth2);

    pcEthernetDao.create(new PcEthernet(somePc, eth1));

But I am quite unsure how I so I get all the data that belongs to a Pc back. I was kind of expecting the

    PC pc = pcDao.queryForId(1);

to automagically retrieve the data of the other tables. Isn’t that what an ORM is supposed to do? Having an object so I do not need to care about the underlying database? Yet all I got is indeed just the Pc.object which only has the PC-defined attributes. (On the other hand, it is not that surprising, as I am only dealing on the pcDao.)

Yet how am I supposed to build a query so that I get a “meta-object” that contains all the data belonging to a PC? An object that includes the data of the PC, and a list the ethernetDevices belonging to the Pcs (that include their own list of Dns-adresses as well), as well as a list of Software and Operating systems.

Am I now supposed to manually solve the dependencies? Query a Pc, ask the PcEthernet-table to get matching Ids, retrieve the EthernetDevice, and so on?

Or is there a trick I am not quite grasping yet?

  • 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-05-27T16:23:12+00:00Added an answer on May 27, 2026 at 4:23 pm

    @Emmanuel’s answer is good but I thought I’d add some context. He is correct that you will need to manage at least some of this relationship yourself.

    Isn’t that what an ORM is supposed to do?

    Yes, although ORMLite is constantly fighting the “size versus feature-set” war. It was designed and built to be a “Lite” ORM and to this end it will never support a full complement of ORM features like Hibernate or iBatis does.

    What you can do with ORMLite and your dataset is to have, as @Emmanuel mentioned, a @ForeignCollectionField in both your Pc and Ethernet objects.

    public class Pc {
        @DatabaseField(generatedId = true)
        private long id;
        @ForeignCollectionField
        private ForeignCollection<PcEthernet> pcEthernets;
        ...
    }
    

    When you retrieve a Pc, a separate query will fill in the pcEthernets. But you will then need to do the queries to get the associated Ethernet objects yourself.

    There have been requests before to automatically generate the join tables and automatically do the IN query. If you want to outline how it would work or assist in the development, be sure to join the ORMLite developers mailing list.

    Lastly, in this case, do you really need a many-to-many relationship? Doesn’t the Ethernet object only have one Pc object?

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

Sidebar

Related Questions

I just started using Kohana a couple days ago, and I have a few
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using SVN, and I have a cache directory that I don't
Just started using log4net and trying to get my head around the config and
I just started using EF, and heres what I have: dataEntity = new ThisProject.Data.Entities();
Just started using carrierwave with Rails and things have been going smoothly with one
Just started using fadein/fadeout - it's functioning but with problems. I have a set
I just started using Coderush and found some stuff that I used to have
I just started using AutoTest. As far as i can tell i have everything

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.