How to access to a Business Object?

1
0
-1

Hi,

I'm trying to get access to a row in a Businnes Object from an external process (I cannot access from context) but I cannot do this, I get the following exception:

  1. {"exception":"class org.bonitasoft.engine.bpm.process.ProcessExecutionException","message":"USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceCreationException: PROCESS_DEFINITION_ID=5085018177039517831 | PROCESS_NAME=Edit supplier | PROCESS_VERSION=0.0 | org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: groovy.lang.MissingMethodException: No signature of method: static com.company.model.SupplierDAO.findById() is applicable for argument types: (java.lang.Long) values: [49]\nPossible solutions: findAll(), find(), findAll(groovy.lang.Closure), find(groovy.lang.Closure)"}

This is my code:

  1. import com.company.model.Supplier;
  2. import com.company.model.SupplierDAO;
  3.  
  4. Supplier sp = SupplierDAO.findById(Long.parseLong(supplierSupplier.get("persistenceId")));
  5. sp.setName(supplierSupplier.get("name"));
  6. sp.setDescription(supplierSupplier.get("description"));
  7. return sp;

What's wrong with my code?, am I trying to access properly?

===== UPDATE =====

This is so frustrating, I'm trying to access via query, but I get this error:

  1. Error: {"exception":"class org.bonitasoft.engine.bpm.process.ProcessExecutionException","message":"USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceCreationException: PROCESS_DEFINITION_ID=5317399391776196580 | PROCESS_NAME=Edit supplier | PROCESS_VERSION=0.0 | org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: PROCESS_INSTANCE_ID=3 | Declared return type class com.company.model.Supplier is not compatible with evaluated type class com.company.model.Supplier_$$_jvst635_9a for expression Supplier.findById"}

???? :(

=============== Thanks in advance.

Comments

Submitted by romain.bioteau on Thu, 07/09/2015 - 10:35

Hi, try casting the persistence id into long like this, and be carefull to use 'supplierDAO' and not 'SupplierDAO'

  1. import com.company.model.Supplier;
  2. import com.company.model.SupplierDAO;
  3.  
  4. Supplier sp = supplierDAO.findById(supplierSupplier.persistenceId.toLong())
  5. sp.name = supplierSupplier.name
  6. sp.description= supplierSupplier.description
  7. return sp;
Submitted by dbravo on Thu, 07/09/2015 - 16:39

Hi Romain,

Thanks for your comment. I tried it but I got this:

  1. Error: {"exception":"class org.bonitasoft.engine.bpm.process.ProcessExecutionException","message":"USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceCreationException: PROCESS_DEFINITION_ID=5207291381939884011 | PROCESS_NAME=Edit supplier | PROCESS_VERSION=0.0 | org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: PROCESS_INSTANCE_ID=11 | Declared return type interface com.company.model.SupplierDAO is not compatible with evaluated type class com.company.model.server.SupplierDAOImpl for expression supplierDAO"}
No answers yet.
Notifications