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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:17:41+00:00 2026-06-02T20:17:41+00:00

I have this abstract class: DomainItem abstract public class DomainItem { @DatabaseField(generatedId = true)

  • 0

I have this abstract class:

DomainItem

abstract public class DomainItem {

    @DatabaseField(generatedId = true)
    protected long id;

    @ForeignCollectionField(eager = false)
        protected ForeignCollection<ContentItem> contentItens;

    //getters and setters
}

ContentItem:

abstract public class ContentItem {

    @DatabaseField(generatedId = true)
    protected long id;

    @DatabaseField(foreign = true)
    protected DomainItem domainItem;


    @DatabaseField()
    protected String content;

    //getters and setters
}

And these (no abstract):

@DatabaseTable()
public class PhytoterapicItem extends DomainItem{

    public PhytoterapicItem(){

    }

}

PhytoterapicContent

@DatabaseTable(tableName = "phytoterapiccontent")
public class PhytoterapicContent extends ContentItem {

    @DatabaseField(canBeNull = false)
    private String defaultName;

    @DatabaseField(canBeNull = false)
    private String scientificName;

    //getters and setters
}

In my DatabaseHelper I trying create the tables:

//DatabaseHelper
...
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
    try {
        Log.i(TAG, "onCreate");
        TableUtils.createTable(connectionSource, PhytoterapicContent.class);
        Log.i(TAG, "Created table PhytoterapicContent");

        TableUtils.createTable(connectionSource, PhytoterapicItem.class);
        Log.i(TAG, "Created table PhytoterapicItem");
    catch{
       ...
    }

The table PhytoterapicContent is created. But I got the follow error:

java.sql.SQLException: Foreign collection class br.com.project.model.ContentItem for field ‘contentItens’ column-name does not contain a foreign field of class br.com.project.model.PhytoterapicItem

  • 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-02T20:17:43+00:00Added an answer on June 2, 2026 at 8:17 pm

    So the exception message was designed to help here. To quote it with the class names removed:

    Foreign collection class ContentItem for field contentItens column-name does not contain a foreign field of class PhytoterapicItem

    That looks to be the case. Whenever you have ForeignCollection, the class contained by the collection must have a foreign field back to the parent class.

    In your case, PhytoterapicItem extends the DomainItem class which has a ForeignCollection of ContentItem objects. That means that ContentItem must have a foreign field of type PhytoterapicItem. Otherwise, how would ORMLite know which of the ContentItem items in the table are associated with a particular PhytoterapicItem.

    The example of Account and Order objects in the foreign collection documentation may help you with your schema. Each Account has a foreign collection of Order objects. Whenever you query for an Account a separate query is performed to find the collection of Order objects that correspond to a particular Account. That means that each Order has to have a foreign Account object.

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

Sidebar

Related Questions

I have this class: public abstract class Directory { protected int id; protected File
I have a model that looks something like this: public abstract class Parent {
Let's say I have something like this: abstract class Parent { protected function foobar($data)
I get runtime error when I do this. I have this class: public abstract
I have this simple interface/class: public abstract class Message {} public class Message1 extends
I have something like this: public abstract class Menu { public Menu() { init();
Let's say that I have this: public abstract class myClass<T> : Ob<T> where T
Let's say I have this class: public abstract class CustomerCollectionBase : Collection<Customer>{} One of
I have this code structure: public abstract class ContentEntryBase { public string UniqueIdentifier; public
Suppose I have something like this: public abstract class AbstractDataObject { public abstract void

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.