I've been using EJB3 with jboss for a long time - and I've got use to this way of writing my ejb3 persistence queries:
entityManager.createQuery("Select e from "+MyEntity.class.getName()+" e")
which is also convenient considering refactoring compared to "Select e from MyEntity e".
But the EJB3 persistence spec says this:
"Entities are designated in query strings by their entity names. The entity name is defined by the name
element of the Entity annotation (or the entity-name XML descriptor element), and defaults to
the unqualified name of the entity class. Entity names are scoped within the persistence unit and must be
unique within the persistence unit."
And glassfish complains about the fully qualified classnames - it just want the unqualified classname (without package information).
According to the spec - glassfish seems more correct to me - but the hibernate/jboss way of using fqn seems better to me - so I wonder, which one is really correct..
Update: class.getSimpleName() does the job - and keeps the refactoring possibility
entityManager.createQuery("Select e from "+MyEntity.class.getName()+" e")
which is also convenient considering refactoring compared to "Select e from MyEntity e".
But the EJB3 persistence spec says this:
"Entities are designated in query strings by their entity names. The entity name is defined by the name
element of the Entity annotation (or the entity-name XML descriptor element), and defaults to
the unqualified name of the entity class. Entity names are scoped within the persistence unit and must be
unique within the persistence unit."
And glassfish complains about the fully qualified classnames - it just want the unqualified classname (without package information).
According to the spec - glassfish seems more correct to me - but the hibernate/jboss way of using fqn seems better to me - so I wonder, which one is really correct..
Update: class.getSimpleName() does the job - and keeps the refactoring possibility
Comments
entityManager.createQuery....I dont know.
can I get an example to
create a string(query)
and setter
and getter
??
thanks