Object relationship mapping

34 views
Skip to first unread message

Brian Hayward

unread,
Mar 23, 2013, 2:37:24 AM3/23/13
to mo...@googlegroups.com
What am I doing wrong?  This is with latest 0.50 daily build.  The last log statement at the end fails with:
Uncaught Error: Invalid value for argument: oneFn Value: undefined
In persistence.js when calling itemone.children.one()

Regards,
Brian

----CODE-----
application Problems

import mobl::ui::generic

screen root() {
        header("Problems")
        script {
                //resetDatabase();
                init();
                }
}

entity Item1 {
        name : String
        children : Collection<Item2> (inverse: parent)
}

entity Item2 {
        name : String
        parent : Item1 (inverse: children)
}


function init ()
{
        var item = Item1.all().one();
        if(item == null)
        {
                log("creating!");
                var it2 = Item2();
                it2.name = "Item 2";
                var it1 = Item1();
                it1.name = "Item 1";
                it2.parent = it1;
                add(it1); 
                it1.children.add(it2);
                // I've tried doing with or without explicitly adding it2.
        }
        var itemone = Item1.all().one();
        log("itemone: " + itemone.name);
        log("itemone child: " + itemone.children.one().name);
}



Chris Melman

unread,
Mar 23, 2013, 5:46:07 AM3/23/13
to mo...@googlegroups.com
Hi Brain,
 
That is indeed strange, looks like it should work, you are sure you have the correc object?
since the other collection and one call is working fine. I'm pretty sure i have used it in similar way in my code where it works.
 
could you look what happens if you remove the inverse on the parent property? i'm not sure but I never used it on a non collection property
 
greeting chris

Date: Fri, 22 Mar 2013 23:37:24 -0700
From: bhay...@gmail.com
To: mo...@googlegroups.com
Subject: [mobl] Object relationship mapping
--
You received this message because you are subscribed to the Google Groups "mobl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobl+uns...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Brian Hayward

unread,
Mar 23, 2013, 5:26:50 PM3/23/13
to mo...@googlegroups.com
I removed inverse on parent, this didn't have any impact.
...added a sleep(3000) just to see if there were any timing issues:
...completely uninstalled the plugin in eclipse and re-installed the latest snapshot (0.50).

After resetDatabase() and running it again, the data in the DB looks correct. There is a single Item1 and a single Item2 and the relationship is there (parent column of Item2 maps to the right Item1 id).  

Here is the updated init() code. The relationship from child back to parent is ok.  Only parent => children relationship seems to fail.  (Same error as before)

The code for the entire project is in this email if you want to try it in your env and see if I'm missing something in my local configuration.

function init ()
{
        var item = Item1.all().one();
        if(item == null)
        {
                log("creating!");
                var it2 = Item2();
                it2.name = "Item 2";
                var it1 = Item1();
                it1.name = "Item 1";
                it2.parent = it1;
                add(it1);
                it1.children.add(it2);
                add(it2);
        }
        sleep(3000);
        var itemone = Item1.all().one();
        var itemtwo = Item2.all().one();
        log("itemone: " + itemone.name);
        log("itemtwo: " + itemtwo.name);
        log("itemtwo parent: " + itemtwo.parent.name);
        log("itemone child: " + itemone.children.one());
}


Regards,
Brian

Brian Hayward

unread,
Mar 24, 2013, 11:13:10 PM3/24/13
to mo...@googlegroups.com
I've tried this mapping both with 0.45 and the latest 0.50 and neither seem to work for me.

Is there a way to put a try/catch around that last log message that's causing the error here?  I'm trying to extend this project to reproduce a couple of other issues I'm having and the standard javascript style try/catch doesn't work.  I couldn't find any references to exception handling in the available mobl documentation.

Also, does mobl have a test suite?

Regards
Brian

Chris Melman

unread,
Mar 25, 2013, 4:10:37 AM3/25/13
to mo...@googlegroups.com
There is no try catch as far as I know, the way I normally do it is to set breakpoints in the generate js code to find where it goes wrong.
 
Indeed it seems like a problem that is there already for a long time since there has been no changes to the model part of mobl
 
mobl is lacking some testing functionality, there are only the test apps that are used to look if they still compile and manual testing.
The harder part is to have testing for UI since this is not really trivial, but most important part of mobl apps
 
greetings Chris
 

Date: Sun, 24 Mar 2013 20:13:10 -0700
From: bhay...@gmail.com
To: mo...@googlegroups.com
Subject: [mobl] Re: Object relationship mapping
Reply all
Reply to author
Forward
0 new messages