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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:27:42+00:00 2026-06-15T10:27:42+00:00

I created database, for my android app, witch has 16 tables. I want to

  • 0

I created database, for my android app, witch has 16 tables. I want to use ORMlite mapping. The problem is that I didn’t find examples where you have composite id(Multiple primary keys). For example I have table:

CREATE  TABLE IF NOT EXISTS `Tourist_Guide`.`Cultural_activity` (
  `City_Id` INT NOT NULL ,
  `activity_Id` INT NOT NULL ,
  `Cultural_activity_Id` INT NOT NULL AUTO_INCREMENT ,
  `Name_Of_Cultural_activity` VARCHAR(30) NOT NULL ,
  PRIMARY KEY (`Cultural_activity_Id`, `City_Id`, `activity_Id`) ,
  INDEX `fk_Cultural_activity_activity1` (`City_Id` ASC, `activity_Id` ASC) ,
  CONSTRAINT `fk_Cultural_activity_activity1`
    FOREIGN KEY (`City_Id` , `activity_Id` )
    REFERENCES `Tourist_Guide`.`activity` (`City_Id` , `activity_Id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

Can you, please, tell me how to map this table to class(how this class should look like), is that even possible?

  • 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-15T10:27:43+00:00Added an answer on June 15, 2026 at 10:27 am

    Limitations

    For simplicity, and to be able to have the same POCO class persisted in db4o, memcached, redis or on the filesystem (i.e.
    providers included in ServiceStack), each model must have a single
    primary key, by convention OrmLite expects it to be Id although you
    use [Alias("DbFieldName")] attribute it map it to a column with a
    different name or use the [PrimaryKey] attribute to tell OrmLite to
    use a different property for the primary key.

    You can still SELECT from these tables, you will just be unable to
    make use of APIs that rely on it, e.g. Update or Delete where the
    filter is implied (i.e. not specified), all the APIs that end with
    ById, etc.

    Workaround single Primary Key limitation

    A potential workaround to support tables with multiple primary keys is
    to create an auto generated Id property that returns a unique value
    based on all the primary key fields, e.g:

    public class OrderDetail
    {
        public string Id { get { return this.OrderId + "/" + this.ProductId; } }
    
        
    
    public int OrderId { get; set; }
        public int ProductId { get; set; }
        public decimal UnitPrice { get; set; }
        public short Quantity { get; set; }
        public double Discount { get; set; }
    }
    

    https://github.com/ServiceStack/ServiceStack.OrmLite/#limitations

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

Sidebar

Related Questions

I'm making Android app that has this database in it: public void onCreate(SQLiteDatabase db)
I have an Android application that uses the Android database to create tables and
I am having problem with the database access in android. First, I created an
i am creating an app that needs a database. i created it using sqlite
We've got an android app and an iPhone app (same functionality) that use sqlite
I am having another problem with my android app which I can't find an
I want to develop an Android app, which stores results in a database. This
I am creating an app that needs a database. I created it using sqlite
We're designing an Android app that has a lot of data (customers, products, orders...),
I have a problem with my database in Android app. Here's some code: private

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.