Foren
Possible to use 'Projections' in DynamicQuery to limit the properties?
Stef Heyenrath, geändert vor 14 Jahren.
Possible to use 'Projections' in DynamicQuery to limit the properties?
Junior Member Beiträge: 76 Beitrittsdatum: 03.12.08 Neueste Beiträge
I've the following entity defined in service.xml:
The description is defined as a CLOB so this can be very long.
Is it possible to use a DynamicQuery and set the projections to only competenceId and title ? And automatically map this to an entity ?
Like this ?
<entity name="Competence" local-service="true" remote-service="true">
<column name="competenceId" type="long" primary="true" />
<column name="title" type="String" />
<column name="description" type="String" />
</entity>
The description is defined as a CLOB so this can be very long.
Is it possible to use a DynamicQuery and set the projections to only competenceId and title ? And automatically map this to an entity ?
Like this ?
public Competence getCompetenceNoDescription(final long competenceId) throws SystemException {
final DynamicQuery query = DynamicQueryFactoryUtil.forClass(Competence.class);
query.setProjection(ProjectionFactoryUtil.property("competenceId"));
List<object> list = dynamicQuery(query);
if (list != null && list.size() == 1) {
return (Competence) list.get(0);
}
return null;
}<br><br>Or is there a better way ?</object>