Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Single Location for the Named Queries

Hi Samba,

Any code contribution you make should be through bugzilla - that is a requirement from the Eclipse foundation.


Samba wrote:
Hi Eclipse Link Community,
I think many people might have felt that annotating the named queries on entites is difficult to maintain over time and some times confusing in a way that finding a proper entity to place the query will be difficult in case of queries that fetch details from several entities. There is already enough frustration documented about this on the bloggosphere, for example: here <> and here <>. How about a cental place like a constants file where we can put all related named queries in one class, like the one below? @*QueryCollection*( @NamedQuery(name=NamedQueries.fetchAnnualSalaryOfAnEmployee,
                 , FROM Employee Emp JOIN
Employee.manager Mgr JOIN Emp.department Dept WHERE
public class NamedQueries {
private static final String fetchAnnualSalaryOfAnEmployee="fetchAnnualSalaryOfAnEmployee"; private static final String fetchEmployeeHierarchy="fetchEmployeeHierarchy"; } And then we can refer to these while executing the queries from the same constants file like: Query query=em.createNamedQuery(NamedQueris.fetchAnnualSalaryOfAnEmployee);
I have implemented this feature in EclipseLink by using the same metadata processing framework that is used for dealing with named queries on entities. I'm attaching the code as zip file to this mail : [ one annoation, one meta data processing class, a patch file showing the changes made to some four or five eclipselink classes, sample entities for testing, and a test case] Please review attached code and let me know how to formally contribute this feature to the eclipselink project. Thanks and Regards,


eclipselink-dev mailing list

Back to the top