日期字段的数据截断

时间:2014-02-11 15:17:03

标签: mysql hibernate

我在struts2 + hibernate应用程序中遇到了一个错误。我试图在数据库上保存实体,然后收到此异常消息:

Incorrect date value: '' for column 'data_creazione' at row 1

这是我的代码:

...
    DocumentoCondivisoDAO cdao = new  DocumentoCondivisoDAO();
    DocumentoCondiviso doc = new DocumentoCondiviso("test_document", "mime/tipe", new Date(), 100000, utente, null);        
    cdao.save(doc);

这是调试信息:

Hibernate: insert into ts_documenti_condivisi (data_creazione, id_destinatario, dimensione_documento, nome_documento, id_proprietario, tipo_documento) values (?, ?, ?, ?, ?, ?)

16:05:08,798 TRACE TimestampType:133 - binding '2014-02-11 16:05:03' to parameter: 1
16:05:08,798 TRACE TimestampType:133 - binding '2014-02-11 16:05:03' to parameter: 1
16:05:08,798 TRACE TimestampType:133 - binding '2014-02-11 16:05:03' to parameter: 1
16:05:08,808 TRACE IntegerType:126 - binding null to parameter: 2
16:05:08,808 TRACE IntegerType:126 - binding null to parameter: 2
16:05:08,808 TRACE IntegerType:126 - binding null to parameter: 2
16:05:08,819 TRACE IntegerType:133 - binding '111111' to parameter: 3
16:05:08,819 TRACE IntegerType:133 - binding '111111' to parameter: 3
16:05:08,819 TRACE IntegerType:133 - binding '111111' to parameter: 3
16:05:08,827 TRACE StringType:133 - binding 'documento' to parameter: 4
16:05:08,827 TRACE StringType:133 - binding 'documento' to parameter: 4
16:05:08,827 TRACE StringType:133 - binding 'documento' to parameter: 4
16:05:08,834 TRACE IntegerType:133 - binding '27' to parameter: 5
16:05:08,834 TRACE IntegerType:133 - binding '27' to parameter: 5
16:05:08,834 TRACE IntegerType:133 - binding '27' to parameter: 5
16:05:08,842 TRACE StringType:133 - binding 'aas' to parameter: 6
16:05:08,842 TRACE StringType:133 - binding 'aas' to parameter: 6
16:05:08,842 TRACE StringType:133 - binding 'aas' to parameter: 6
16:05:08,966 ERROR JDBCExceptionReporter:78 - Data truncation: Incorrect date value: '' for column 'data_creazione' at row 1
16:05:08,966 ERROR JDBCExceptionReporter:78 - Data truncation: Incorrect date value: '' for column 'data_creazione' at row 1

我想澄清一下,另一个类中的相同代码就像一个魅力......我做错了什么?

EDIT1:构造函数

public DocumentoCondiviso(String nomeDocumento, String tipoDocumento, Date dataCreazione,
                            int dimensioneDocumento, Utenti proprietario, Utenti destinatario){

    this.nomeDocumento = nomeDocumento;
    this.tipoDocumento = tipoDocumento;
    this.dataCreazione = dataCreazione;
    this.dimensioneDocumento = dimensioneDocumento;
    this.proprietario = proprietario;
    this.destinatario = destinatario;

}

MySQL数据库上的字段类型是" DATE" ....我有很多与此类似的实体正常工作。

0 个答案:

没有答案