We have generic abstract class GenericDependency and several implementing subclasses.
In persistence.xml we have them in this order:
The problem occured when using criteria api:
In child there were reference to Artifact instead of Release so it throws exception on the 3rd line as it can't found project attribute on Artifact.
The reason is that when building metamodel, ArtifactArtifactDependency is processed first and it's superclass GenericDependency metamodel is build with attributes child and parent as Artifact.
When building metamoded for ArtifactReleaseDependency, the superclass metamodel is reused resulting in wrong thinking that child attribute is Artifact instead of Release.