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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:38:55+00:00 2026-05-31T10:38:55+00:00

When writing an instance of my data class to the database via ORMLite, and

  • 0

When writing an instance of my data class to the database via ORMLite, and one of the child members (a foreign field) is null, I get back a non null child member.

Data classes as follows:

public class Site {
    //  snip
    @DatabaseField(foreign = true, canBeNull = true)
    private InstallationType installationType;
}

public class InstallationType {   
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField
    private String name;
}

When I read my instance of the Site class again via

getSiteDao().queryForId(id);

the installationType member is non null, but with a non-existent id. The only way the rest of our application can now work with this object, is if I manually do a lookup through the InstallationTypeDAO and set what I get back on the site. Query will sometimes return null as per the documentation.

Is there a way of getting ORMLite to set this member to null?

  • 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-31T10:38:57+00:00Added an answer on May 31, 2026 at 10:38 am

    This was a bug in ORMLite that was fixed in version 4.15 (3/7/2011). Here’s the change log file. What version are you using? Have you tried to update? Here’s the bug report page:

    Currently the following test passes so I think we have good coverage on that bug.

    @Test
    public void testForeignNull() throws Exception {
        Dao<Foreign, Integer> dao = createDao(Foreign.class, true);
        Foreign foreign = new Foreign();
        foreign.foo = null;
        assertEquals(1, dao.create(foreign));
        Foreign foreign2 = dao.queryForId(foreign.id);
        assertNotNull(foreign2);
        assertNull(foreign2.foo);
    }
    

    With Foreign having the following fields:

    @DatabaseField(generatedId = true)
    public int id;
    @DatabaseField(foreign = true)
    public Foo foo;
    

    If you are up to date in versions, please let me know if you can change the test to get it to fail.

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

Sidebar

Related Questions

I'm writing a small sqlalchemy shim to export data from a MySQL database with
Hi I am writing a linked list data type. I have an inner class
I'm writing a windows service that's required to retrieve data from a database, build
While writing yet another class full of methods that access database tables to work,
Suppose I'm writing an SNMP v1/2 agent. Is it mandatory to append the instance
Reading about Delphi's Exit statement (see here for instance), I cannot ignore that writing
I'm writing a factory class that should be able to return singleton instances of
One of my fellow developer has a code similar to the following snippet class
Im writing a C# class library component which is going to act as a
I started writing a small wrapper class to take care of my excel operations:

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.