icatproject / icat.server

The ICAT server offering both SOAP and "RESTlike" interfaces to a metadata catalog.
Other
1 stars 5 forks source link

It's not possible to update investigations with parameters through the REST API #276

Open WHTaylor opened 2 years ago

WHTaylor commented 2 years ago

Hi, I was getting some errors last week whilst trying to update some investigations on our ICAT instance via the REST API. I eventually worked out that it was only failing on investigations which had parameters, and found the cause in InvestigationParameter::preparePersist:

https://github.com/icatproject/icat.server/blob/f86b255fc7ab43cdcb55876b57966c22ff39b08a/src/main/java/org/icatproject/core/entity/InvestigationParameter.java#L43

After this, the entity manager tries to merge the entity back into the database with a call to flush() which fails because the primary key can't be null (EntityBeanManager:2102). It works when creating new investigations because persist() generates a new ID for anything without one. It also works through the SOAP API, because EntityBeanManager::update doesn't use preparePersist.

Would it be possible to remove the problem line entirely? InvestigationParameter is the only entity which does this, and it doesn't seem like useful behaviour, but it's been around since 2014 so possibly something depends on it.