The JPA Metamodel does not allow to retrieve the actual EmbeddableType since all instances are registered by the associated Java type

Description

Hello,

It is possible to get a FALSE executing something like this:

where Address is an @Embeddable.

The problem is here:

This is creating a new EmbeddableTypeImpl each time an @Embeddable is used on a different Attribute.
The problem is that EmbeddableTypeImpl (and also its class hierarchy) doesn't implement equals() so each instance is compared for equivalence as with ==.

I see 2 simple solutions:

  1. prevent the duplicated instantiation in getMetaModelType() (maybe using a Map<Class<?>, EmbeddableTypeImpl<?>>)

  2. let EmbeddableTypeImpl (maybe TypeImpl?) implement hashCode() and equals() based on getJavaType() comparison (since it is a natural unique key)

I think the problem is immediate enough to verify just looking at the code snipped, but if you need a Test Case, I'll do it asap.

If you decide to accept any of the proposed solutions, I can try to solve it and submit a PR on github.

Thank you

Environment

Wildfly 10.1.0

Status

Assignee

Vlad Mihalcea

Reporter

Michele Mariotti

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure