lovespring
lovespring

Reputation: 19569

For an entity, Is it posible to use different name in HQL than the class name

I have a Dao layer, the entity name is long and ugly.

so, I wander if there is a way to use another name for the class name in HQL

I'm using xml config style.

It's a legacy project.

Upvotes: 0

Views: 81

Answers (1)

Angular University
Angular University

Reputation: 43087

You can use the entity-name attribute:

<hibernate mapping>
    <class name="package.UglyName" entiy-name="BetterName" table="table1">
    ...
</hibernate mapping>

And then on the query the entity name can be used instead of the class name:

Session session = SessionFactory.openSession();
List table1List = session.createQuery("FROM BetterName").list();

Upvotes: 2

Related Questions