|
Hi guys,
I want to get an entity from the metamodel based on it's name. My entity is the following:
@Cacheable
@Entity(name = CategoryModel.NAME)
@Table(name = CategoryModel.NAME, uniqueConstraints = { @UniqueConstraint(columnNames = { "pk", "id" }) }, indexes = { @Index(columnList = "id")})
public class CategoryModel extends AbstractEntityModel {
public static final String NAME = "category";
}
so I use:
EntityType<T> type = ((MetamodelImpl) metamodel).getEntityTypeByName("category");
but this returns null. So I examined what is being added in the metamodel and here (EntityBinder:bindEntity:246):
persistentClass.setEntityName( annotatedClass.getName() );
looks like you are always using the classname of the entity, and not the name parameter of the @Entity annotation. This means that I can never get the entity by it's name.
|