JPA2: how access entity name for projection query [message #712447] |
Sun, 07 August 2011 08:55 |
darren Messages: 19 Registered: March 2011 Location: Sydney, Australia |
Junior Member |
|
|
By entity name I mean the value of the name attribute of the @Entity annotation, which defaults to the simple class name of the entity class.
The information is there in the database form of a DTYPE column - I am using a "supertable" @Inheritance(strategy=InheritanceType.JOINED) - but I don't know how to expose this information in a projection query.
grateful for suggestions,
Webel IT Australia
[Updated on: Sun, 07 August 2011 08:56] Report message to a moderator
|
|
|
|
|
Re: JPA2: how access entity name for projection query [message #713751 is a reply to message #713747] |
Tue, 09 August 2011 00:41 |
darren Messages: 19 Registered: March 2011 Location: Sydney, Australia |
Junior Member |
|
|
I don't want to confuse matters with 2 parallel message threads here, but they are in fact asking separate things.
This thread is asking how to access the entity name for a projection query, and James has suggested that TYPE() does return the entity name, and that would seem to agree with this example from Pro JPA2 p.262:
SELECT p.name, CASE WHEN TYPE(p) = DesignProject THEN 'Development' ..
Here 'DesignProeject' is clearly an entity name.
But a constructor expression to accept a TYPE() using a String fails with a request for a java.lang.Class. So I am not convinced that TYPE() in the context of a projection query result is returning the entity name.
The thread at: http://www.eclipse.org/forums/index.php/mv/msg/233012/712438/#msg_712438 (TYPE() fails in projection query result: EclipseLink ConversionException) is specifically asking about the use of TYPE() in a projection query, where it was intended to elicit the fully qualified class, not the entity name.
I in fact need both the entity name and the fully qualified class.
If I have one (from an entity query) I can always find the other outside the query result, by examining the metamodel (once at application startup then caching map of entity name to entity class, or vice versa).
But as it stands I can currently access neither entity name nor entity class.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02398 seconds