How to write Update query in activeobject entity

1.4k views Asked by At

How can we write update entity ActiveObject - com.atlassian.activeobjects.external.ActiveObjects.

Any one please share me the stuff.

I am using create entity activeobject stuff as below and it works fine:

    en pi = ao.executeInTransaction(new TransactionCallback() // (1)            
        {   
             @Override
             public en doInTransaction()
             {
                logger.info("before ao.create");
                en pi = ao.create(enclass);
                                    ....

                pi.save();                              
                return pi;          
             }
        });

Thanks

2

There are 2 answers

0
aberes On BEST ANSWER

Select the id, set your data in the testAO and finaly save it.

            public Object doInTransaction(){
                TestAO testAO = ao.get(TestAO.class,issueXXX.getId());
                testAO.setError(issueXXX.getError());
                testAO.save();
                return null;
            }

You can update only one by one, this is the easy way.

0
John Galt On

I did it this way

ao.executeInTransaction(new TransactionCallback<Void>() {
        @Override
        public Void doInTransaction() {
           Formulario form = ao.get(Formulario.class,id_ingresado);
           form.setName(nombre_ingresado);
           form.setLastName(apellido_ingresado);
           form.setDate(fecha_ingresada);
           form.setPhone(telefono_ingresado);
           form.save();
           return null;
        }