Let\'s say I have entity Foo like -
package com.some.company.model;
// imports
@Entity
public class Foo{
@Id
private Long id;
// getters / s
For non-entity class, you have to provide also package (getName()) HQL query cannot solve if you have more than one class which are extended by different entities : "from com.hello.AbstractEntity"
I don't think it makes a difference, but... I prefer unqualified name simply because it is shorter and it makes my HQL easier to comprehend. The only reason I can think of to use fully qualified name is you have 2 different Foo
entities (say, from different packages), in this case, I would much rather map them into different entity names (say, AFoo
, BFoo
) rather using fully qualified names to differentiate them.
There is no point to use the fully qualified name because Hibernate won't allow duplicate entity names. So if you had different entities with the same name, in different packages. Hibernate will throw a DuplicateMappingException.