Representing list of polymophic objects in db

Let's suppose I have a list of derived objects from some base:
class Circle : public Shape;
class Rectangle : public Shape;
There is object, which has vector of Shape * as member variable:
class Screen {
std::vector<Shape *> shapes_;
But now I need to persist this in database (PostgreSQL to be precise). Only way I thought of is to have table per class, something like this:
table screen ();
table circle (
int screen_id;
table rectangle (
int screen_id;
And after retrieving from object of type Screen do query for Circles and Rectangles with screen.id. Should be doable.
However I fear that when number of types grows (and it will), it would mean many db queries for just one object retrieval/persist.
Right know we'll have about 10 types I think? That's 11 db queries just to retrieve one Screen object.
So my questing is, is there better way to achieve my goal? I'm fine with redesigning my code if needed, I just would like some O(1) solution in correlation to number of types (my solution is O(n) ).
Thank you guys ^_^
NOTE: based on comment I'm adding that tables of Circles and Rectangles etc. will be used
only to put together Screen object. I don't access (look-up, retrieve, persist, ...) to them individually, only as parts of Screen(s). They don't even have to be in their own table. Just didn't find a way to nicely put it all together :/

All you need is one table, with a simple design. You need
A field for the uid
Possibly a field for a timestamp (you may need that, you may not, don't know your particular circumstances).
A field in which you serialize the Screen object and all the Shapes it contains.
That means just one write to save and one read to recover the Screen and its shapes. Why do more, given how simple your requirements are?
I recommend you serialize to a json format. Postgresql now has a JSON data type and JSON operators and functions. So you can validate and examine the serialized data in the db if you want to, without having to extract and normalize it.
Other benefits of this approach:
If you later decide to serialize somewhere else (into a file or memory cache, for example), it would require minimal change to the code.
No need to change your db schema if you add new types of Shapes or change the structure of any existing objects.

Similar Messages

  • How to find out a list of modified objects in an SAP system

    Hi all, not sure if this is the right place to ask.
    In preparation for an upcoming upgrade of a SAP 4.6c system, I have been asked to generate a list of SAP objects that have been modified over the years.
    Is there a table or a report that I can use to find this out? Thanks!

    Hi,
    Please check the table TADIR. From that table u can get the modified object details.
    thanks,
    Senthil Kumar.C

  • How to get list of custom objects used in abap report program?

    Hi friends,
    I have a requirement in which I have to scan the entire abap report and retrieve list of custom objects used in it for example custom tables, data elements, structures, table types etc,. Is there any provision in SAP like fuction modules to do this functionality?  As of now I am coding everything manually where so many possibilities are there for all kinds of objects. Provide your answers and suggestions...
    Thanks,
    Nastera

    Hi,
    The best way to do this is environment analysis. Follow the steps:
    1. Open se38, type in the program name (don't click on on display/change or create button, stay on first screen only)
    2. Click on environment analysis button (hot key SHIFT+F4)
    3. It will throw a pop-up, which will ask for type of object you want to see, which are linked /used by this program. select all (or may be if you are only interested in Tables, then select table only)
    4. Hit 'Enter'
    You will get the full list of all objects used in this report program. Just note down the one which starts with Z or Y and that's it.
    Cheers,
    Anid

  • Creating smartform from attachment list of service object

    Hi,
       How can i create a smartform containing attachment list from generic object services(active workflow Box) in tcode VA02, Also let me know in which table this attachment lists are stored.
    Thanks,
       JP

    I found following Solution:
    I copied the following classes and changed them in some way to fit my requirements:
    1.CL_GOS_ATTACHMENTS
    2.CL_GOS_SRV_ATTACHMENT_LIST
    3.CL_LIST_BROWSER
    Changes to the Classes:
    1.Type of the attribute GO_INSTANCE changed to ZCL_GOS_ATTACHMENTS.
       Changed method INIT_BROWSER:
    go_browser ?=
        zcl_list_browser=>zcreate_browser( cl_browser=>gc_list_browser ).
    2.Type of the attribute GO_ATTACHMENT_LIST changed to ZCL_GOS_ATTACHMENTS
    3. Copied Method CREATE_BROWSER of Class CL_BROWSER to ZCREATE_BROWSER:
    method zcreate_browser.
      case ip_btype.
        when gc_list_browser.
          *create object ro_browser type zcl_list_browser.*
        when gc_tree_browser.
          create object ro_browser type cl_tree_column_browser.
        when others.
          raise exception type cx_sobl_browser
            exporting
              gp_error = cx_sobl_browser=>gc_wrong_type
          exit.
      endcase.
    endmethod.
    Modified the code of method ___DISPLAY to my needs.

  • Disable pushbuttons from Attachment list for Service Object

    Hi,
    I want to disable push buttons for delete and edit from the toolbar of Attachment list from service objects.
    how can this be achieved ?
    thanks in advance.
    Best Regards,
    Vinayaka

    Hi Sandeep,
    I am not totallt getting your point but can suggest following points:
    1. Check whether these object are displaying in DIR's as object links.
    2. If it is there then it shoud be displayed in document data of those objects.
    3. Check that documents are properly checked-in.
    Hope this may help.
    Regards,
    Ravindra

  • List of business objects

    Hi all,
    Is it possible in the DI API to get a list of business objects (for example business partners) from the Company object or do I have to use a recordset with an SQL statement? If so, how. And if not, where do I find a translation of tablenames (e.g.: AACP, INV6 etc.) to business objects.
    This seems a pretty generic question, but I cannot seem to find the answer. Does anyone have a pointer to good reading on the DI API subject?
    Thanks!
    Best regards.
    Chris G.

    Hi Chris,
    this is an excerpt from the SDK Help file.
    It works on other object too, of course.
    Private Sub DataBrowserOperations()
        '// A Data Browser object can not be created, it is invoked
        '// as a property of a business object.
        '// The BusinessPartners object is used to demonstrate the
        '// use of a DataBrowser object
        Dim BusinessPartners As SAPbobsCOM.BusinessPartners
        '// A DataBrowser object contains a Recordset object.
        '// Because a DataBrowser Object can not be created,
        '// a Recordset Object should be created and then assigned
        '// (linked) to the Recordset Property of the DataBrowser
        Dim oRecordSet As SAPbobsCOM.Recordset
        '// Get a new BusinessPartners object
        Set BusinessPartners = oCompany.GetBusinessObject(oBusinessPartners)
        '// Get a new Recordset object
        Set oRecordSet = oCompany.GetBusinessObject(BoRecordset)
        '// Perform the SELECT statement.
        '// The query result will be loaded
        '// into the Recordset object
        oRecordSet.DoQuery ("Select cardcode from ocrd where cardtype = 'C'")
        '// Asign (link) the Recordset object
        '// to the Browser.Recordset property
        BusinessPartners.Browser.Recordset = oRecordSet
        '// Access the data
        '// Once the Browser points to a row in the
        '// result set you can use the properties directly
        BusinessPartners.CardCode
        BusinessPartners.CardName
        '//Get the next Business Partner
        If BusinessPartners.Browser.EOF = False Then
            BusinessPartners.Browser.MoveNext
        End If
        '//Get the previous Business Partner
        If BusinessPartners.Browser.BoF = False Then
            BusinessPartners.Browser.MovePrevious
        End If
    End Sub

  • How do i get a list of all objects in a combo box

    I want to get the list of all Objects in a JComboBox. I appreciate your help! Thanks!

    I already know the solution with getItemCount and
    then the for loop with getItemAt. I'm curios if there
    exist somethig like Object[] getAllItems()If it's not in the API, then it's not available. You can create your own ComboBoxModel that will return an Object[] of elements and call setModel on your combobox.

  • How to Enable Ratings on SharePoint List using Client Object Model for Office 365 SharePoint Site.

    How to Enable Ratings on SharePoint List using Client Object Model code for Office 365 SharePoint Site.
    Thanks in Advance
    Rajendra K

    Hi Rajendra,
    here you are the code and the blog, let me know if this helps
    using (ClientContext ctx = new ClientContext(https://yourSiteUrl))
    Web w = ctx.Web;
    List l = w.Lists.GetByTitle("yourListName");
    ctx.Load(l, info => info.Id);
    ctx.ExecuteQuery();
    string ListID = l.Id.ToString();
    Microsoft.Office.Server.ReputationModel.Reputation.SetRating(ctx, ListID, 1, 5);
    ctx.ExecuteQuery();
    http://blogs.technet.com/b/speschka/archive/2013/07/08/how-to-use-csom-with-ratings-in-sharepoint-2013.aspx
    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

  • List of Info Objects used in a process chain

    Hi,
    I have a master data process chain and in that process chain, close to about 50 Info objects are included. Rather than checking manually, I would like to know if there is any automated way to get the list of info objects used in a process chain.
    Please let me know if there is any table that gives this information.
    Thanks & Regards.

    following transparent tables store Process Chain related data... there you might get the information you are looking for..
    RSEVENTCHAIN       Event Chain Processing Event Table
    RSEVENTHEAD        Header for the event chain
    RSEVENTHEADT        Header for the event chain
    RSPCCHAIN     Process chain details
    RSPCCHAINATTR      Attributes for a Process Chain
    RSPCCHAINEVENTS      Multiple Events with Process Chains
    RSPCCHAINT      Texts for Chain
    RSPCCOMMANDLOG     System Command Execution Logs (Process Chains)
    RSPCLOGCHAIN      Cross-Table Log ID / Chain ID
    RSPCLOGS     Application Logs for the Process Chains
    RSPCPROCESSLOG     Logs for the Chain Runs
    RSPCRUNVARIABLES      Variables for Process Chains for Runtime
    RSPC_MONITOR     Monitor individual process chains
    Regards,
    Sharayu

  • List of all objects in the data dictionary

    How to capture the list of all objects in the data dictionary named like PSDFDI and verify they are granted to the FDIREADR role

    See the database security guide http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm#BABFHBFH
    Finding Information About User Privileges and Roles
    This section discusses the system views that have the grant information.
    The tricky part of this is that because roles can be granted to other roles the data is hierarchical.
    So start with the grants made to the FDIREADR role. So referring to the doc above;
    select * from role_role_privs where role = 'FDIREADR'will list the roles granted to your role.
    You will want to look at ROLE_ROLE_PRIVS, ROLE_TAB_PRIVS and ROLE_SYS_PRIVS.
    I suggest you walk thru the views manually to see how the information is related. Then write a test script that queries the views for you.

  • List of unnassigned objects in the integration directory

    Hi! Hope this is an easy question. Does anyone know of a way to get a list of all objects - party, service, rec det etc... - that are not assigned to a Config Scenario in the integration directory. Need to do a cleanup and wants to avoid going object by object to get the list. Thx, Duncan

    Thanks for the replies. The objects tab shows me all objects. I need to see only those not assigned to a CS. How can I do that there?
    The where used option requires me to go trhough every object (1000+) and check one by one. That is what I am trying to avoid.
    Ideas? Thx, Duncan

  • Get hierarchal list of business objects

    Hi,
      I'm using SWO_QUERY_OBJTYPES to get a list of business objects, but I need to display a hierarchy similar to the BAPI explorer. What business object can I use to browse business objects? If no business object is available, what function calls are available to get at the data?

    Hi Chris,
    this is an excerpt from the SDK Help file.
    It works on other object too, of course.
    Private Sub DataBrowserOperations()
        '// A Data Browser object can not be created, it is invoked
        '// as a property of a business object.
        '// The BusinessPartners object is used to demonstrate the
        '// use of a DataBrowser object
        Dim BusinessPartners As SAPbobsCOM.BusinessPartners
        '// A DataBrowser object contains a Recordset object.
        '// Because a DataBrowser Object can not be created,
        '// a Recordset Object should be created and then assigned
        '// (linked) to the Recordset Property of the DataBrowser
        Dim oRecordSet As SAPbobsCOM.Recordset
        '// Get a new BusinessPartners object
        Set BusinessPartners = oCompany.GetBusinessObject(oBusinessPartners)
        '// Get a new Recordset object
        Set oRecordSet = oCompany.GetBusinessObject(BoRecordset)
        '// Perform the SELECT statement.
        '// The query result will be loaded
        '// into the Recordset object
        oRecordSet.DoQuery ("Select cardcode from ocrd where cardtype = 'C'")
        '// Asign (link) the Recordset object
        '// to the Browser.Recordset property
        BusinessPartners.Browser.Recordset = oRecordSet
        '// Access the data
        '// Once the Browser points to a row in the
        '// result set you can use the properties directly
        BusinessPartners.CardCode
        BusinessPartners.CardName
        '//Get the next Business Partner
        If BusinessPartners.Browser.EOF = False Then
            BusinessPartners.Browser.MoveNext
        End If
        '//Get the previous Business Partner
        If BusinessPartners.Browser.BoF = False Then
            BusinessPartners.Browser.MovePrevious
        End If
    End Sub

  • How to Retrieve a List of Business Objects using DI Server?

    In DI Server (and DI-API) I could not find how I can get a list of business objects, for instance ServiceCall objects.
    and more - say i need the list with a filter on customer code and call status?

    ...at least not to the extent that you are looking for.
    Please check the E-learning:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d78ab1f9-0901-0010-8495-8ca0facaea2e?prtmode=navigate
    at: https://www.sdn.sap.com/irj/sdn/businessone-elearning
    ...or go the sample code for the DataBrowser (sub-)object in the "SDK Help Center"...
    ...or go to the DI API sample (no. 2 I think I remember).
    ...to find out how you can navigate between the records of the result of your SQL query; from there you could e.g. export the objects to XML...
    HTH

  • List with multiple objects

    Hi,
    Is it possible can we have a List with multiple Object (CustomerVO, OrderVO and AddressVO) in a single List? If so how we will define the generics for that List?
    Please clarify.
    Thanks.

    797836 wrote:
    Guys, am I correct? Please clarify.If it works, it is correct. So try it.
    I was more thinking along the line of this though according to what you described in your initial post:
    Class ParentVO{
    private CustomerVO customer;
    private OrderVO order;
    private AddressVO address;
    // with getters and setters
    }That way you don't need any list at all, if you only want to have access to these three objects. Just slap them in a ParentVO and use that.
    Looking at it again I wonder if the ParentVO is needed even, there is a strong relationship between these three objects. An order has a customer and a customer has an address / an order has a billing/shipping address...

  • To find the list of Inactive objects in the Production system.

    Hi Experts,
      Need a help. I want to find the List of inactive objects in the Production system. Do we have any standard program or any transcation code to find.
    Appreciate your help.
    Thanks,
    Venkata.A

    Check below threads -
    Check Inactive Objects in System
    Need program to find the inactive objects
    Tcode for finding out the inactive BI Objects

Maybe you are looking for

  • Incoming MAC Mail Bouncing

    Half of my incoming emails are bouncing. When I send an email through my MAC account to his MAC account, it bounces back at me. I've had MAC mail for 3 years and have been experiencing this since May. What is going on?

  • OTA update despite formerly open bootloader?

    Hi there, some time ago I had my boot loader unlocked. But I locked it again with flash tool. Currently I use a pre rooted Lollipop I installed via recovery. What I find strange is, I get a message about a system update and I get this message via OTA

  • Intel HD Graphics 4000 lag?

    I've been using my rMBP for about 6 months now; however I have noticed video and UI lage while using the integrated gpu "Intel HD Graphics 4000." When I switch the Nvidia GeForce 650M, there is no more lag in both UI and video playback. Is there anyw

  • HT202825 Where do I find the security code to turn on keychain?

    Hi, I have problems to approve my Mac from another device. There is a request for the Security Code to turn on the iCloud key chain. Where do I find the security code? I do not recall being issued one or making up a code. Thank you, BB69

  • DON'T LIKE THE NEW CALENDAR

    I don't like the new calendar.  It doesn't show events for the day like the old one did.  You have to scroll around to find them.  Better to have them at the bottom of that day so you can see them readily.