title: null value in column violates not-null constraint
body: <p>I have sql error null value in column "kladr_full_name" violates not-null constraint.</p>
  
  <p>Table in database to wich request is performed: </p>
  
  <pre><code>СREATE TABLE kladr.kladr_name
  (
    kladr_code character varying(255) NOT NULL,
    kladr_city_name character varying(121),
    kladr_full_name character varying(487) NOT NULL,
    kladr_index character varying(6),
    kladr_name character varying(100) NOT NULL,
    kladr_naspunkt_name character varying(121),
    kladr_rayon_name character varying(121),
    kladr_region_name character varying(121),
    kladr_socr character varying(20),
    CONSTRAINT kladr_name_pkey PRIMARY KEY (kladr_code )
  )
  WITH (
    OIDS=FALSE
  );
  ALTER TABLE kladr.kladr_name
    OWNER TO postgres;
  </code></pre>
  
  <p>Request to db:</p>
  
  <pre><code>    INSERT INTO kladr.kladr_name 
              (kladr_code, 
               kladr_name, 
               kladr_socr, 
               kladr_index, 
               kladr_region_name, 
               kladr_rayon_name, 
               kladr_city_name, 
               kladr_naspunkt_name, 
               kladr_full_name) 
  SELECT kladr_code, 
         Upper(kladr_name)                 kladr_name, 
         kladr_socr, 
         kladr_index, 
         (SELECT k1.kladr_socr 
                 ||' ' 
                 ||k1.kladr_name 
          FROM   kladr.kladr_tmp k1 
          WHERE  k1.kladr_region = k.kladr_region 
                 AND k1.kladr_rayon = '000' 
                 AND k1.kladr_city = '000' 
                 AND k1.kladr_nas_punkt = '000' 
                 AND k1.kladr_mod = '00' 
                 AND k1.kladr_status = '0')kladr_region_name, 
         (SELECT k1.kladr_socr 
                 ||' ' 
                 ||k1.kladr_name 
          FROM   kladr.kladr_tmp k1 
          WHERE  k1.kladr_region = k.kladr_region 
                 AND k1.kladr_rayon = k.kladr_rayon 
                 AND k1.kladr_rayon &lt;&gt; '000' 
                 AND k1.kladr_city = '000' 
                 AND k1.kladr_nas_punkt = '000' 
                 AND k1.kladr_name = '00') kladr_rayon_name, 
         (SELECT k1.kladr_socr 
                 ||' ' 
                 ||k1.kladr_name 
          FROM   kladr.kladr_tmp k1 
          WHERE  k1.kladr_region = k.kladr_region 
                 AND k1.kladr_rayon = k.kladr_rayon 
                 AND k1.kladr_city = k.kladr_city 
                 AND k1.kladr_city &lt;&gt; '000' 
                 AND k1.kladr_nas_punkt = '000' 
                 AND k1.kladr_mod = '00')  kladr_city_name, 
         (SELECT k1.kladr_socr 
                 ||' ' 
                 ||k1.kladr_name 
          FROM   kladr.kladr_tmp k1 
          WHERE  k1.kladr_region = k.kladr_region 
                 AND k1.kladr_rayon = k.kladr_rayon 
                 AND k1.kladr_city = k.kladr_city 
                 AND k1.kladr_nas_punkt = k.kladr_nas_punkt 
                 AND k1.kladr_nas_punkt &lt;&gt; '000' 
                 AND k1.kladr_mod = '00')  kladr_naspunkt_name, 
         (SELECT k1.kladr_socr 
                 ||' ' 
                 ||k1.kladr_name 
          FROM   kladr.kladr_tmp k1 
          WHERE  k1.kladr_region = k.kladr_region 
                 AND k1.kladr_rayon = '000' 
                 AND k1.kladr_city = '000' 
                 AND k1.kladr_nas_punkt = '000' 
                 AND k1.kladr_mod = '00' 
                 AND k1.kladr_status = '0') 
         ||' ' 
         ||(SELECT k1.kladr_socr 
                   ||' ' 
                   ||k1.kladr_name 
            FROM   kladr.kladr_tmp k1 
            WHERE  k1.kladr_region = k.kladr_region 
                   AND k1.kladr_rayon = k.kladr_rayon 
                   AND k1.kladr_rayon &lt;&gt; '000' 
                   AND k1.kladr_city = '000' 
                   AND k1.kladr_nas_punkt = '000' 
                   AND k1.kladr_mod = '00') 
         ||' ' 
         ||(SELECT k1.kladr_socr 
                   ||' ' 
                   ||k1.kladr_name 
            FROM   kladr.kladr_tmp k1 
            WHERE  k1.kladr_region = k.kladr_region 
                   AND k1.kladr_rayon = k.kladr_rayon 
                   AND k1.kladr_city = k.kladr_city 
                   AND k1.kladr_city &lt;&gt; '000' 
                   AND k1.kladr_nas_punkt = '000' 
                   AND k1.kladr_mod = '00') 
         ||' ' 
         ||(SELECT k1.kladr_socr 
                   ||' ' 
                   ||k1.kladr_name 
            FROM   kladr.kladr_tmp k1 
            WHERE  k1.kladr_region = k.kladr_region 
                   AND k1.kladr_rayon = k.kladr_rayon 
                   AND k1.kladr_city = k.kladr_city 
                   AND k1.kladr_nas_punkt = k.kladr_nas_punkt 
                   AND k1.kladr_nas_punkt &lt;&gt; '000' 
                   AND k1.kladr_mod = '00')kladr_full_name 
  FROM   kladr.kladr_tmp k 
  WHERE  k.kladr_mod = '00' 
  </code></pre>
  
  <p>DB postgreSql. jpa prov hibernate. What could be the reason of this?</p>
  
  <p>Question now is how to modify this query to work in postgres(before it was working in oracle db) if some subquerys returns null?</p>