How to get rid of the log when inserting record into partitioned table?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get rid of the log when inserting record into partitioned table?

igilfanov
Grails 2.2.4
postgreSQL 9.1
postgresql-9.2-1000.jdbc4.jar


try{    
                                 
    fooBar
.save(flush:true, failOnError:true)  

}catch(org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException ex){
                                                               
     
if(ex.message.indexOf('row count: 0; expected: 1') == -1){
           
throw ex
     
}

}

Log errors after inserting record:

 Error 2014-08-03 14:45:07,206 [quartzScheduler_Worker-3] ERROR jdbc.AbstractBatcher  - Exception executing batch:
Message: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

Error 2014-08-03 14:45:07,248 [quartzScheduler_Worker-3] ERROR events.PatchedDefaultFlushEventListener  - Could not synchronize database state with session
Message: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/d6fae53c-92ce-4a5b-b6e4-cc25d20b08a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to get rid of the log when inserting record into partitioned table?

igilfanov
Мay have to use a design sessionFactory.currentSession.createSQLQuery :-(

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/c6eeb003-462f-45ad-ad4d-be9cd9f43dc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to get rid of the log when inserting record into partitioned table?

igilfanov
In reply to this post by igilfanov
CREATE TABLE parttemp
(
  id serial NOT NULL
,
  test_field integer
,
  CONSTRAINT parttemp_pkey PRIMARY KEY
(id)
)
WITH
(
  OIDS
=FALSE
);

CREATE TABLE parttemp_1
(
  id integer NOT NULL DEFAULT nextval
('parttemp_id_seq'::regclass),
  test_field integer
,
  CONSTRAINT parttemp_1_pkey PRIMARY KEY
(id)
)
INHERITS
(parttemp)
WITH
(
  OIDS
=FALSE
);

CREATE OR REPLACE FUNCTION insert_parttemp_trig
()
  RETURNS trigger AS
$BODY$
BEGIN
 
  INSERT INTO parttemp_1 VALUES
(NEW.*);

  RETURN NULL
;

END; $BODY$
  LANGUAGE plpgsql VOLATILE
  COST
100;


CREATE TRIGGER insert_parttemp_trigger
  BEFORE INSERT
  ON parttemp
  FOR EACH ROW
  EXECUTE PROCEDURE insert_parttemp_trig
();


import org.hibernate.SessionFactory
import foo.bar.PartTemp

class BootStrap {

 
def init = { servletContext ->

   
//new PartTemp(test_field: 27999).save(flush:true, failOnError:true)
   
//
   
//ERROR jdbc.AbstractBatcher  - Exception executing batch:
   
//Message: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1                  
   
//
   
//ERROR events.PatchedDefaultFlushEventListener  - Could not synchronize database state with session
   
//Message: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

       
def sqlQuery = sessionFactory.currentSession.createSQLQuery("INSERT INTO parttemp(test_field) VALUES(?)")
        sqlQuery
.setInteger(0, 27999)
        sqlQuery
.executeUpdate()
               
       
PartTemp.createCriteria().get {                    
           projections
{
              max
("test_field")
           
}
       
}.each{                                
           println it
==27999
       
}

 
}

}


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/2e03ab3e-5c06-41d8-b3d8-1d7432c867dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.