title: No Dialect mapping for JDBC type: -101 Exception While Using Named Query in Hibernate
body: <p>I am trying to execute a query in hibernate using Named Query. But, while execution I am getting Hibernate Mapping Exception. Can any one please help me to identify the problem.</p>
  
  <blockquote>
    <p>Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC
    type: -101
            at org.hibernate.dialect.TypeNames.get(TypeNames.java:79)
            at org.hibernate.dialect.TypeNames.get(TypeNames.java:104)
            at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:442)
            at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:586)
            at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:512)</p>
  </blockquote>
  
  <p>SQL:</p>
  
  <pre><code>&lt;sql-query name="orderSummaryASN"&gt;
  SELECT 
            "ORDER_TYPE","ORDER_DOC_ID","TYPE_ORDER","ORDER_NUMBER","VERSION_NUMBER","RELEASE_NUMBER","ORDER_DATE","BUYER_IDENTIFIER","SUPPLIER_IDENTIFIER","LINE_ID_KEY","ITEM_NUMBER",
        "ITEM_DESCRIPTION","ORDER_QUANTITY","BUYER_PART_NUMBER","SELLER_PART_NUMBER","STANDARD_PART_NUMBER","DEPARTMENT_CODE","UNIT_OF_MEASURE","QUALIFIER_CODE","SCHEDULE_ID",
      "SCHEDULE_NUMBER","REQUESTED_QUANTITY","RECEIVED_QUANTITY","TOTAL_INVOICED_QUANTITY","DRAFT_INVOICED_QUANTITY","BALANCE_TO_SHIP_QUANTITY","SHIP_QUANTITY",
      "TEMPLATE_NAME","REFERRED_DOCUMENT_TYPE","USER_DOC_ID","ID","ORDER_DATE_TZ","MESSAGE_TYPE","TRANSACTION_DATE","TRANSACTION_DATE_TZ","IS_ACTIVE",
      "OBJ_VERSION","RTD_VERSION","CREATED_BY","CREATED_TS","LAST_MODIFIED_BY","LAST_MODIFIED_TS","EXTERNAL_ID","LAST_MODIFIED_TS_TZ","CREATED_TS_TZ" 
  FROM    ( SELECT 
          order_type,order_doc_id,type_order,order_number,version_number,release_number,order_date,buyer_identifier,supplier_identifier,
          line_id_key,item_number,item_description,order_quantity,buyer_part_number,seller_part_number,standard_part_number,department_code,unit_of_measure,qualifier_code,
          schedule_id,schedule_number,requested_quantity,received_quantity,total_invoiced_quantity,draft_invoiced_quantity ,
          (requested_quantity - total_shipped_quantity) as balance_to_ship_quantity,
          (requested_quantity - (draft_shipment_quantity + total_shipped_quantity)) as ship_quantity,
          'VIEW_ORDER_SUMMARY_ASN' as template_name, referred_document_type, rownum as user_doc_id,rownum as id,order_date_tz, message_type,transaction_date,transaction_date_tz,
          1 as is_active,1 AS obj_version, 1 AS rtd_version, '' AS created_by,SYSTIMESTAMP AS created_ts, '' AS last_modified_by,
          SYSTIMESTAMP AS last_modified_ts, '' AS external_id,'Asia/Calcutta' AS last_modified_ts_tz,'Asia/Calcutta' AS created_ts_tz 
      FROM(
          select case when poh.TEMPLATE_NAME in ('PO_DOC', 'PO_RESPONSE_DOC') then 'Purchase Order'
          when poh.TEMPLATE_NAME in ('CO_DOC', 'CO_RESPONSE_DOC') then 'Call-off Order'
          when poh.TEMPLATE_NAME in ('SO_DOC', 'SO_RESPONSE_DOC') then 'Sales Order'
          end as order_type,poh.USER_DOC_ID as order_doc_id,poh.ORDER_TYPE as type_order,poh.ORDER_NUMBER as order_number,poh.RELEASE_NUMBER as release_number,poh.VERSION_NUMBER as version_number,
          poh.ORDER_DATE as order_date,buyer.COMP_ID as buyer_identifier,supplier.COMP_ID as supplier_identifier,pod.LINE_ID_KEY as line_id_key,pod.ITEM_NUMBER as item_number,
          pod.ITEM_DESCRIPTION as item_description,pod.ORDER_QUANTITY as order_quantity,pod.BUYER_PART_NUMBER as buyer_part_number,pod.SELLER_PART_NUMBER as seller_part_number,
          pod.STANDARD_PART_NUMBER as standard_part_number,pod.department_code as department_code,pod.unit_of_measure as unit_of_measure,pos.QUALIFIER_CODE as qualifier_code,
          pos.SCHEDULE_ID as schedule_id,pos.SCHEDULE_NUMBER as schedule_number,case poh.order_type when 'Original' then nvl(pos.REQUESTED_QUANTITY, 0) else nvl(pos.RESPONSE_QUANTITY, 0) end as requested_quantity,
          pos.RECEIVED_QUANTITY as received_quantity,nvl(pos.TOTAL_SHIPPED_QUANTITY, 0) as total_shipped_quantity, nvl(pos.DRAFT_SHIPMENT_QUANTITY, 0) as draft_shipment_quantity, 
          nvl(pod.TOTAL_INVOICED_QUANTITY,0) as total_invoiced_quantity , nvl(pod.DRAFT_INVOICED_QUANTITY,0) as draft_invoiced_quantity, null, poh.template_name as referred_document_type,
          poh.USER_DOC_ID as user_doc_id,poh.ORDER_DATE_TZ as order_date_tz, poh.MESSAGE_TYPE as message_type, poh.transaction_date as transaction_date,poh.transaction_date_tz as transaction_date_tz
      FROM 
          AO_PO_HEADER poh,AO_PO_DETAIL pod,AO_PO_DTL_SCHEDULE pos,mdm_company_hdr buyer,mdm_company_hdr supplier where (poh.USER_DOC_ID=pod.USER_DOC_ID and pod.USER_DOC_ID=pos.USER_DOC_ID and 
          pod.ID=pos.PARENTLINEID and poh.BUYER_IDENTIFIER=buyer.ID and poh.SUPPLIER_IDENTIFIER=supplier.ID and poh.ORDER_TYPE not in ('Change') and poh.OBSOLETE_ORDER = 0 and 
          poh.BUSINESS_STATUS not in ('Draft', 'Frozen') AND ((poh.order_type = 'Original' AND (pod.BUSINESS_STATUS IS NULL OR pod.BUSINESS_STATUS not in ('Cancelled'))) OR pod.ORDER_ACTION not in ('Rejected'))
          AND (pos.last_shipment_flag != 1 or pos.last_shipment_flag is null))
          )
      ) 
  WHERE
      ship_quantity &gt; 0 and message_type is not null and (exists(select BIZSETTINGS.IS_ACTIVE from PARTY BUYER, PARTY SUPPLIER, BUSINESS_RULES BIZ_RULES, BUSINESS_RULE_SETTINGS BIZSETTINGS where
      BUYER.PARTY_ID = buyer_identifier and SUPPLIER.PARTY_ID = supplier_identifier and BIZ_RULES.RULE_NAME='rule.name.order.allow.multiple.targets'
      and BIZ_RULES.ID = BIZSETTINGS.BUSINESS_RULES_ID and BIZSETTINGS.BUYER_ID = BUYER.ID and (BIZSETTINGS.SUPPLIER_ID = SUPPLIER.ID or (not exists (select brs.id from BUSINESS_RULE_SETTINGS brs where brs.BUYER_ID = BUYER.ID and brs.SUPPLIER_ID = SUPPLIER.ID)))
      and BIZSETTINGS.IS_ACTIVE=1) or  ((draft_invoiced_quantity &amp;lt;= 0 and total_invoiced_quantity &amp;lt;= 0)  and
      not exists (select sub_poh.id from AO_PO_HEADER sub_poh where sub_poh.ORDER_USER_DOC_ID = order_doc_id and sub_poh.BUSINESS_STATUS in('Draft', 'Submitted', 'Pending')))) and
      (exists (select PTYPE.ID from PROCESS_TYPE PTYPE, MESSAGE_FLOW MF, PROCESS_TYPE_ASSOC PASSO, MESSAGE_TYPE SMT, MESSAGE_TYPE TMT, DOCUMENT_MASTER SDM, DOCUMENT_MASTER TDM, PARTY BPARTY, PARTY SPARTY
      WHERE MF.PROCESS_ID = PTYPE.ID and PASSO.PROCESS_ID = PTYPE.ID and PTYPE.PARTY_ID = BPARTY.ID and PASSO.SUPPLIER_PARTY_ID = SPARTY.ID and BPARTY.PARTY_ID = buyer_identifier and SPARTY.PARTY_ID = supplier_identifier and MF.SRC_MSG_ID = SMT.ID and MF.TGT_MSG_ID = TMT.ID and
      SMT.DOC_TEMPLATE_ID = SDM.DOCUMENT_TEMPLATE_ID and TMT.DOC_TEMPLATE_ID = TDM.DOCUMENT_TEMPLATE_ID and SMT.MESSAGE_TYPE_NAME = message_type and TDM.DOCUMENT_TEMPLATE_NAME = 'ASN_DOC') or
      exists (select PTYPE.ID from PROCESS_TYPE PTYPE, MESSAGE_FLOW MF, MESSAGE_TYPE SMT, MESSAGE_TYPE TMT, DOCUMENT_MASTER SDM, DOCUMENT_MASTER TDM, PARTY BPARTY
      where MF.PROCESS_ID = PTYPE.ID and PTYPE.PARTY_ID = BPARTY.ID and BPARTY.PARTY_ID = buyer_identifier and MF.SRC_MSG_ID = SMT.ID and MF.TGT_MSG_ID = TMT.ID and
      SMT.DOC_TEMPLATE_ID = SDM.DOCUMENT_TEMPLATE_ID and TMT.DOC_TEMPLATE_ID = TDM.DOCUMENT_TEMPLATE_ID and SMT.MESSAGE_TYPE_NAME = message_type and   TDM.DOCUMENT_TEMPLATE_NAME = 'ASN_DOC' and PTYPE.DEFAULT_PROCESS_TYPE=1))
  &lt;/sql-query&gt;
  </code></pre>
  
  <p>Java:
      Query query = getSession().getNamedQuery(namedQuery);
      list = query.list();</p>