Adding children to custom extension elements (Java Model API)

I have created custom extension classes (as explained in Access custom extension elements with the BPMN Model API), but am having trouble adding or setting children to them.

CustomMetadata metaElem = extensionElements.addExtensionElement(CustomMetadata.class);
		
PropertyId propId = modelInstance.newInstance(PropertyId.class);
		
propId.setTextContent(this.id);
		
metaElem.setPropertyId(propId);

When it gets to set or add child it throws an exception

New child is not a valid child element type: map; valid types are:

I can not use addChildElement method, got the same error.
When checking log, it alway use ModelElementInstanceImpl.addChildElement but not ExtensionElementsImpl.addChildElement.
So I use ExtensionElementsImpl.addChildElement method content like:

customMetadataElemet.getDomElement().appendChild(childExtensionElement.getDomElement())

and it worked.

This is what I did in the end as well, but I still wanted to know why this doesn’t work. I’d much rather use my setters instead of using this workaround.