Im Attachment
Domain neues Feld hinzufügen Long fileBytesLength
und innerhalb Mapping Closure die Formel zur Berechnung der Länge von fileBytes
hinzufügen Feld.
class Attachment {
String createUserName
String originalFilename
byte[] fileBytes
Long fileBytesLength
Date dateCreated
//Other Properties
static mapping = {
//Other mappings
fileLength formula: "dbms_lob.getlength(fileBytes)"
}
}
Und ändern Sie dann die Abfrage zu:
def results = Attachment.executeQuery(
'select id, originalFilename, fileBytesLength, dateCreated, createUserName '+
'from Attachment a where a.id not in '+
'(select attachmentId from SpecVersion sv where sv.attachmentId is not null) '+
'and a.dateCreated > sysdate - 30')