Search in sources :

Example 1 with OrdinalParameterDescriptor

use of org.hibernate.engine.query.spi.OrdinalParameterDescriptor in project hibernate-orm by hibernate.

the class NativeQueryInterpreterStandardImpl method getParameterMetadata.

@Override
public ParameterMetadataImpl getParameterMetadata(String nativeQuery) {
    final ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations(nativeQuery);
    final int size = recognizer.getOrdinalParameterLocationList().size();
    final OrdinalParameterDescriptor[] ordinalDescriptors = new OrdinalParameterDescriptor[size];
    for (int i = 0; i < size; i++) {
        final Integer position = recognizer.getOrdinalParameterLocationList().get(i);
        ordinalDescriptors[i] = new OrdinalParameterDescriptor(i, null, position);
    }
    final Map<String, NamedParameterDescriptor> namedParamDescriptorMap = new HashMap<String, NamedParameterDescriptor>();
    final Map<String, ParamLocationRecognizer.NamedParameterDescription> map = recognizer.getNamedParameterDescriptionMap();
    for (final String name : map.keySet()) {
        final ParamLocationRecognizer.NamedParameterDescription description = map.get(name);
        namedParamDescriptorMap.put(name, new NamedParameterDescriptor(name, null, description.buildPositionsArray(), description.isJpaStyle()));
    }
    return new ParameterMetadataImpl(ordinalDescriptors, namedParamDescriptorMap);
}
Also used : ParamLocationRecognizer(org.hibernate.engine.query.spi.ParamLocationRecognizer) HashMap(java.util.HashMap) OrdinalParameterDescriptor(org.hibernate.engine.query.spi.OrdinalParameterDescriptor) NamedParameterDescriptor(org.hibernate.engine.query.spi.NamedParameterDescriptor) ParameterMetadataImpl(org.hibernate.query.internal.ParameterMetadataImpl)

Aggregations

HashMap (java.util.HashMap)1 NamedParameterDescriptor (org.hibernate.engine.query.spi.NamedParameterDescriptor)1 OrdinalParameterDescriptor (org.hibernate.engine.query.spi.OrdinalParameterDescriptor)1 ParamLocationRecognizer (org.hibernate.engine.query.spi.ParamLocationRecognizer)1 ParameterMetadataImpl (org.hibernate.query.internal.ParameterMetadataImpl)1