Commit is excluding attributes

I am having a problem where a commit is excluding one attribute when executed in one place but not any others. I have a class ‘Event’ with an attribute ‘assetShip’ which is a many-to-many association with the ‘actShips’ entity. I have several views, all of which include the ‘assetShip’. When I retrieve the ‘Event’ entities in my service bean (using either DataManager or EntityManager), it correctly returns the appropriate ‘assetShip’ attribute.

Within the service bean, I am also programatically creating new 'Event’s and committing them using the following lines.


CommitContext commitContext = new CommitContext(event);
dataManager.commit(commitContext);

These new 'Event’s include the ‘assetShip’ attribute. I am also programatically adjusting other attributes of existing 'event’s and committing those changes with the same code (but not modifying the ‘assetShip’ attribute). When I then retrieve all the ‘Event’ entities again, for all events created within the service bean, the ‘assetShip’ attribute is null. Correct values still exist for the old events that had other attributes modified in the same routine which indicates the retrieval process is still fine.

I have traced the code through the ‘DataManagerBean.java’ code that actually performs the commit and confirmed that the ‘assetShip’ attribute is being properly maintained throughout the entire commit process as far as I can tell.


// method that executes within the DataManagerBean.java file
Set<Entity> commit(CommitContext context))

Can you help troubleshoot where this attribute might be getting discarded or what other causes there might be?

FYI - I have also tried the following commit code to force it to use a view that I know includes the attribute (as evidenced by proper retrieval of the attribute:


dataManager.commit(event, "eventList-view");

but the result is the same. All of the other attributes are properly committed, but just not the ‘assetShip’.

Edit: I was able to do a workaround where (in the service bean) instead of assigning the ship to the event, I assign the event to the ship. This would suggest I have something wrong in my many-to-many relationship. However, when I assign the ship to the event within the Event UI code (committing using a datasource and DSContext), there is absolutely no problem.

ORM saves related collections only for the owning side - in case of ManyToMany it is the one that contains @JoinTable annotation. When Studio creates ManyToMany associations, it makes both sides owning. Could you check how your attributes are defined?

Thanks Konstantin. I think that was the problem. I thought the owning checkmark in cuba studio would be the driver so I assumed I could modify both sides. I ended up going with a one-to-many and changed my rules for handling events. It is simpler and while less flexible, provides a lot simpler processing in other areas of the code.