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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:51:02+00:00 2026-06-01T22:51:02+00:00

I’m experimenting with ORMLite for android. I have a pre built SQLite db that

  • 0

I’m experimenting with ORMLite for android.

I have a pre built SQLite db that i am loading on the android device. I have stored position information as LocationX, LocationY columns:

CREATE TABLE graphicsinstances(Name STRING , LocationX FLOAT , LocationY FLOAT , SizeX FLOAT , SizeY FLOAT );

Catch is, at runtime i’d like this to look something like:

public class Vector2
{
    public float X;
    public float Y;
}
@DatabaseTable(tableName = "graphicsinstances")
public class graphicsinstance
{
    public GraphicalEntityInstance()
    {
        mName               = null;
        mPosition           = Vector2.zero();
        mSize               = Vector2.zero();
    }
    @DatabaseField(columnName = "Name", canBeNull = false)
    public String mName;

    //Olympic standard optimism
    //@DatabaseField(columnName = "Location", canBeNull = false)
    //public Vector2 mPosition;

    // current (unsatisfactory) method:
    @DatabaseField(canBeNull = false, useGetSet=true)
    private float LocationX;
    public float getLocationX() { return mPosition.X;}
    public void setLocationX(float x) { mPosition.X = x;}
    // repeat for Y, SizeX & SizeY!
}

Have I missed something obvious or am I completely barking up the wrong tree? can anyone suggest an alternative/prettier method?

  • 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-01T22:51:03+00:00Added an answer on June 1, 2026 at 10:51 pm

    If I understand, you want to map a table into a class with sub-classes. In your example I guess you want to load the LocationX and LocationY fields into the mposition which I guess is a Vector2?

    I think it is ok to have a getMPosition() and setMPosition(mpos) methods that do the mapping between the LocationX and LocationY fields but you are not going to be able to do that mapping auto-magically with ORMLite.


    From a purity standpoint I always recommend using what database circles call an “entity class”. This class mirrors your database structure exactly. It should have a one-to-one correspondence between fields in the table and the class. It can have methods like hashCode(), equals(), and the standard getter/setters but very little else.

    You could create a wrapping object that takes a GraphicsInstance object in its constructor and does the Vector2 mapping and allows the other operations. When you are ready to persist it when you would need to go back to the GraphicsInstance object.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.