Error loading data of a field that belongs to a class type PropertyBusinessObject

19 views
Skip to first unread message

Rubén V

unread,
Dec 27, 2020, 5:53:10 PM12/27/20
to CodenameOne Discussions
Hi,

First: Merry christmas.

Create a class that calls "Order2" that implements PropertyBusinessObject.

With this class I create a table using the SQLmap api with the following code:

        Database db = null;
        try {
            db = Display.getInstance().openOrCreate(BD);
            SQLMap sqlMap = SQLMap.create(db);

            Orden2 o2 = new Orden2();
            sqlMap.setPrimaryKeyAutoIncrement(o2, o2.id);
            sqlMap.createTable(o2);

        } catch (IOException e) {
            System.out.println("Error: " + e.getMessage());
        } finally {
            Util.cleanup(db);
        }

I am testing the app in debug mode and it does not allow me to change the value of one of the fields (orderId). It always remains with the initial value. In the beginning this field was the primary key, but when it gave me problems I changed it. I have also tried deleting the database from the ".cn1" folder and the problem continues.

The following image shows the content of the field after execution and it is visualized that the value never changed.



Shai Almog

unread,
Dec 27, 2020, 9:54:11 PM12/27/20
to CodenameOne Discussions
Auto-increment essentially means the database will determine the value of the ID field. If you remove that property and clear the database you should be able to specify a value on your own.

Rubén V

unread,
Dec 27, 2020, 10:36:10 PM12/27/20
to CodenameOne Discussions
Hi,

Thanks for the clarification, but the "orderId" field is currently not Auto-increment. Why is it staying, I can't update its content?

Regards.

Rubén V

unread,
Dec 27, 2020, 10:55:05 PM12/27/20
to CodenameOne Discussions
Hi,

The image shows the contents of the field after the mapping was run. It should have taken the value of "62", but it didn't happen.

Regards.

Shai Almog

unread,
Dec 28, 2020, 10:04:38 PM12/28/20
to CodenameOne Discussions
Hi,
Sorry I misunderstood the question. Are you sure the value of oR1 is correct here?
Did you try stepping into the set call with the debugger to see what's going on there?
Is there an exception thrown along the way?
What's the code of Order2?
Reply all
Reply to author
Forward
0 new messages