Search in sources :

Example 1 with JaxbHbmNativeQueryCollectionLoadReturnType

use of org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryCollectionLoadReturnType in project hibernate-orm by hibernate.

the class NamedQueryBinder method processNamedQueryContentItem.

private static boolean processNamedQueryContentItem(Object content, NamedSQLQueryDefinitionBuilder builder, ImplicitResultSetMappingDefinition.Builder implicitResultSetMappingBuilder, JaxbHbmNamedNativeQueryType namedQueryBinding, HbmLocalMetadataBuildingContext context) {
    if (String.class.isInstance(content)) {
        // Especially when the query string is wrapped in CDATA we will get
        // "extra" Strings here containing just spaces and/or newlines.  This
        // bit tries to account for them.
        final String contentString = StringHelper.nullIfEmpty(((String) content).trim());
        if (contentString != null) {
            builder.setQuery((String) content);
            return true;
        } else {
            return false;
        }
    } else if (JAXBElement.class.isInstance(content)) {
        return processNamedQueryContentItem(((JAXBElement) content).getValue(), builder, implicitResultSetMappingBuilder, namedQueryBinding, context);
    }
    if (JaxbHbmQueryParamType.class.isInstance(content)) {
        final JaxbHbmQueryParamType paramTypeBinding = (JaxbHbmQueryParamType) content;
        builder.addParameterType(paramTypeBinding.getName(), paramTypeBinding.getType());
    } else if (JaxbHbmSynchronizeType.class.isInstance(content)) {
        final JaxbHbmSynchronizeType synchronizedSpace = (JaxbHbmSynchronizeType) content;
        builder.addSynchronizedQuerySpace(synchronizedSpace.getTable());
    } else if (JaxbHbmNativeQueryScalarReturnType.class.isInstance(content)) {
        implicitResultSetMappingBuilder.addReturn((JaxbHbmNativeQueryScalarReturnType) content);
    } else if (JaxbHbmNativeQueryReturnType.class.isInstance(content)) {
        implicitResultSetMappingBuilder.addReturn((JaxbHbmNativeQueryReturnType) content);
    } else if (JaxbHbmNativeQueryJoinReturnType.class.isInstance(content)) {
        implicitResultSetMappingBuilder.addReturn((JaxbHbmNativeQueryJoinReturnType) content);
    } else if (JaxbHbmNativeQueryCollectionLoadReturnType.class.isInstance(content)) {
        implicitResultSetMappingBuilder.addReturn((JaxbHbmNativeQueryCollectionLoadReturnType) content);
    } else {
        throw new org.hibernate.boot.MappingException(String.format(Locale.ENGLISH, "Encountered unexpected content type [%s] for named native query [%s] : [%s]", content.getClass().getName(), namedQueryBinding.getName(), content.toString()), context.getOrigin());
    }
    return false;
}
Also used : JaxbHbmQueryParamType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmQueryParamType) JaxbHbmNativeQueryCollectionLoadReturnType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryCollectionLoadReturnType) JAXBElement(javax.xml.bind.JAXBElement) JaxbHbmSynchronizeType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSynchronizeType) JaxbHbmNativeQueryReturnType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryReturnType)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)1 JaxbHbmNativeQueryCollectionLoadReturnType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryCollectionLoadReturnType)1 JaxbHbmNativeQueryReturnType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryReturnType)1 JaxbHbmQueryParamType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmQueryParamType)1 JaxbHbmSynchronizeType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSynchronizeType)1