I have an entity named Client, And it has some named queries and native named queries. What I want to do is, I want to move this named queries to another class. For that I would like to extend the Client entity by another class ClientQuery. And move all named,native queries to that class. Is it possible to do so?
Client CLASS
@XmlRootElement(name = "CLIENT_DETAILS")
@XmlAccessorType(XmlAccessType.FIELD)
@Entity
@NamedQueries({
@NamedQuery(name = Client.GET_CLIENT_BYLANGID,
query = "select T from Client T where T.clientPK.langId=:langId")
})
public class Client implements Serializable {
public static final String GET_CLIENT_BYLANGID = "Client.getClientByLangId";
As I understand, you want to know whether it correct to move the @NamedQuery
out of the Entityclass to a non-entity class.
I have quickly checked the specification and did not see any restrictions about that. Additionally I have tried to put in an mapping.xml an <named-query>
element outside of the <entity>
element and it is xml-valid, so it is legal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With