Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Is it possible to get the entityAlias used in a JPA query

Is there a way to get the entity aliases used in a JPA query. I am able to
get the field aliases from the DatabaseQuery using the ReportItem, but i
require "entityAlias.fieldAlias" information.

For instance:

If I have the following JPQL

	<named-query name="findPersonInfo" >
		<query>select p.name as personName, p.id as personId, s.name as
studentName from   com.model.Student s, com.model.Person p where p.name =
s.name </query> 
	</named-query>
	
	
In this case for instance, the alias for com.model.Person is 'p'. The
following code returns only field aliases :

		Map<String, String> map = new HashMap<String, String>();
		
		if (databaseQuery.isObjectLevelReadQuery()) {
			List<ReportItem> reportsItems = ((ReportQuery) databaseQuery).getItems();
			for (ReportItem item : reportsItems) {
				String aliasName = item.getName();
				String attributeName = item.getAttributeExpression().getName();
				map.put(aliasName, attributeName);
			}
		}

The above block of code returns the following map :
	{studentName=name, personId=id, personName=name}
		
The required output whereas is to get entityAlias.fieldAlias like the map
mentioned below :
	{studentName=s.name, personId=p.id, personName=p.name}
	
	
Is there a way to get the above mentioned information

Regards
Bhakti



--
View this message in context: http://eclipse.1072660.n5.nabble.com/Is-it-possible-to-get-the-entityAlias-used-in-a-JPA-query-tp155335.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.


Back to the top