Note that there are some explanatory texts on larger screens.

plurals
  1. POClob field not populated in object in grailsChange changeset using grails DSL
    primarykey
    data
    text
    <p>I am making my first migration script that involves the use of the Groovy/Grails DSL. It looks like this:</p> <pre><code>import my.package.MyObject import my.package.MyObjectUtil import javax.xml.bind.DatatypeConverter databaseChangeLog = { changeSet(author: 'wheresjim', id: '1387238199-1') { comment {'Sets the timestamp in each MyObject where null using the message text'} grailsChange { change { MyObjectUtil myObjectUtil = new MyObjectUtil() def criteria = MyObject.where { isNull("timestamp") } def PAGESIZE = 10 int numRows = criteria.count() int pages = Math.ceil(numRows / PAGESIZE) (pages..0).each { page -&gt; int offset = PAGESIZE * page + PAGESIZE def data = criteria.list(offset: offset, max: PAGESIZE, sort: 'id', order: 'asc') data.each { MyObject myObject -&gt; Date timestamp = new Date(0L) try { def thisMessage = myObjectUtil.createMyObjectFromMessage(myObject.messageText) String dateStr = thisMessage.messageIdentification?.timestamp timestamp = dateStr ? DatatypeConverter.parseDateTime(dateStr).getTime() : timestamp } catch (Exception e) { // Do nothing, this will be logged in the finally which catches another error condition } finally { if (timestamp == new Date(0L)) { log.warn "Error attempting to set timestamp in MyObject ${myObject.id}, setting to $eventDateTime" } } myObject.timestamp = timestamp myObject.save(flush: true) } log.warn "Updated ${myObject.id}" } } } } } </code></pre> <p>The <code>MyObject.messageText</code> is a clob in the database, and to my knowledge, there has been no effort to lazily load it.</p> <p>I should note that this exact script works (it can find the clob text) using the grails console plugin on the app.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload