Home » Eclipse Projects » EclipseLink » TYPE() fails in projection query result: EclipseLink ConversionException
| TYPE() fails in projection query result: EclipseLink ConversionException [message #712438] |
Sun, 07 August 2011 04:45  |
darren Messages: 19 Registered: March 2011 Location: Sydney, Australia |
Junior Member |
|
|
EclipseLink2.2
GlassFish3.1
Oracle 10gR2 for Mac OS X.
Netbeans 7
JPA2
JavaEE6
I am exploring using projection queries to expose lightweight slices of otherwise very heavy entities to a JSF user interface.
For want of a better expression I am calling the constructed objects to hold the projection query results "View DTOs", although they are not "across the wire" Data Transfer Objects. Each View DTO contains sufficient information to construct a JSF link with title and an outcome and id as query parameter, but no expensive relationships.
I need, absolutely imperatively, to be able to also access the class of the entity "matching" each View DTO object, and I store this with the View DTO on construction. I am attempting to access this using TYPE() in the query result.
So for example, I have a TagSet entity with a List<Tag> tags. A query for all TagSetView instances matching
every TagSet within a given Project is:
public List<TagSetView> jqpl_tagSetViews(Project project) {
//cf. Special Result Types, Pro JPA2 p.193
return em.createQuery(
"SELECT NEW com.greensoft.entity.dto.tag.TagSetView(TYPE(t),t.id,t.name) "+
"FROM TagSet t "+
"WHERE t.project = :project "+
"ORDER BY t.name",
TagSetView.class)
.setParameter("project",project)
.getResultList();
}
With the View DTO constructor:
public TagSetView(Class entityClass, Long id, String name) {
super(entityClass,id,name);
}
This fails with:
Exception [EclipseLink-3007] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [TagSet], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Ensure that the class [TagSet] is on the
CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager
Internal Exception: java.lang.ClassNotFoundException: TagSet
at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConvertedToClass(ConversionException.java:87)
[I know that TYPE(t) above is giving a java.lang.Class back ok, because if I provoke a construction error by using a constructor TagSetView(String,Long,String)
I get another error message saying that it expects TagSetView.<init>(java.lang.Class, java.lang.Long, java.lang.String).]
I don't see why it could not find the class TagSet. It is a complete Netbeans+Glassfish Java EE6 Web application.
The entities are surely already available to the container-managed transaction-scoped entity manager when
the query is executed.
Very grateful for help on this, as although I can get more limited projection queries working,
I really need to get at the entity class of each row (not so much in this trivial TagSet case,
which is a test run, but in other more complex domain entity class cases, where I need
to provide information on the class of an object alongside information on the object,
where here the actual entity object is in fact represented by the minimal View DTO).
thanks,
Webel IT Australia
|
|
|
 |
|
TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Sun, 07 August 2011 04:45 |
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
|
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
|
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Mon, 08 August 2011 20:07 |
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Mon, 08 August 2011 20:46 |
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Mon, 08 August 2011 21:04 |
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Tue, 09 August 2011 01:05 |
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Tue, 09 August 2011 02:21 |
 |
|
Re: TYPE() fails in projection query result: EclipseLink ConversionException
By: darren on Tue, 09 August 2011 02:31 |
 |
|
(no subject)
By: darren on Tue, 09 August 2011 02:47 |
 |
|
Re: (no subject)
|
 |
|
Re: (no subject)
|
 |
|
Re: (no subject)
By: darren on Thu, 11 August 2011 21:21 |
 |
|
Re: (no subject)
By: darren on Thu, 11 August 2011 22:01 |
 |
|
(no subject)
By: darren on Thu, 11 August 2011 22:01 |
 |
|
(no subject)
By: darren on Tue, 09 August 2011 01:05 |
 |
|
(no subject)
By: darren on Tue, 09 August 2011 02:21 |
Goto Forum:
Current Time: Fri May 24 00:06:42 EDT 2013
Powered by FUDForum. Page generated in 0.01688 seconds
|