How to instantiate a BDM object

Hi,

I would like to use a BDM object but how to instantiate it correctly ?

I have the following error : Impossible to get data of type (name of object) with a null identifier"

Any clue ?

An automatic instantiation of business data are done the first time a setter is called (using a Java Method operator in a operation).
If you use a Groovy Expression, you can use the following code

myBusinessObjectDAO.newInstance('some mandatory attribute')

Ok, maybe it 's working with a groovy script which return a new Object.

Ok may be within the operation tab.
However there is no newInstance method in the DAO interface.

And after init the object, I have this : javax.persistence.PersistenceException : “org.hibernate.PropertyAccessException: could not get a field value by reflection getter of TestOne.persistenceId”

Any idea ?

What version of BonitaBPM are you using ?

6.3.8

ok, snippet above is available in 6.4+
then instantiate like this :

def newBoInstance = new MyBusinessObject() newBoInstance .setMandatoryField1() newBoInstance .setMandatoryField2() return newBoInstance;

Be carefull that your script does not reference the business data you want to instantiate.
That may lead to the above error. (eg; if your business data is called ‘testData’, don’t use testData as variable in your script)

Ok I understand, but it doesn’t work anyway.
I have tried also in 6.4.2
Always the same error (like above)

Here is more complete error in 6.4.2 :

Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of FIRHDataUser.persistenceId
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:62)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:344)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4550)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:129)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:833)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:817)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:821)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:889)
… 28 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field FIRHDataUser.persistenceId to FIRHDataUser
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source)
at java.lang.reflect.Field.get(Unknown Source)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:59)
… 36 more