Unrecognized Entity-name when adding a listener

Description

1. @Entity
@EntityListeners(AuditingEntityListener.class)
public class Customer implements Serializable

2. Customer have two entity-name, example:

<class name="com.example.demo.Customer"
table="customers"
entity-name="Customer">

<id name="id" type="long" column="id" unsaved-value="0">
<generator class="native"/>
</id>
<version name="version" column="version" type="long" unsaved-value="undefined"/>

<property name="code" not-null="true"/>
<property name="description" not-null="true"/>
</class>

<class name="com.example.demo.Customer"
table="customers"
entity-name="CustomerProxy">

<id name="id" type="long" column="id" unsaved-value="0">
<generator class="native"/>
</id>

<version name="version" column="version" type="long" unsaved-value="undefined"/>

<property name="codigo" not-null="true"/>

</class>

3. in persistence , save, saverOrUpdate or merge with the entity-name "Customer"
session.saveOrUpdate(entityName, entity);

4. Error
org.hibernate.MappingException: Unknown entity: com.example.demo.Customer

the problem i thing,

class : org.hibernate.event.internal.DefaultFlushEntityEventListener
method : copyState
line : ClassMetadata metadata = sf.getClassMetadata( entity.getClass() );
lost the entity-name, replace by .getMetamodel()

Environment

None

Assignee

De Carli Gustavo

Reporter

De Carli Gustavo

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure