簡體   English   中英

數據截斷:第 x 行的“xxx”列的數據太長(布爾值)

[英]Data truncation: Data too long for column 'xxx' at row x (boolean)

我正在使用 hibernate 一對多映射來完成我的任務。 但是當我運行這個項目時,它遇到了一個問題:“數據截斷:第 1 行的‘tinhTrang’列數據太長”。 我不明白為什么我得到這個。 我搜索了,但我找不到像我這樣的 boolean 有任何問題。 請幫我。 謝謝大家

.package com.javapoint;
import javax.persistence.*;  

@Entity  
@Table(name="DH")  
public class DonHang { 

@Id  
@GeneratedValue(strategy=GenerationType.TABLE)  
private int soDH;    
private int maKH;  
private double triGia;
@Column(nullable = false, columnDefinition = "TINYINT(4)")
private boolean tinhTrang;

public int getsoDH() 
{  
    return soDH;  
}  
public void setsoDH(int soDH) 
{  
    this.soDH = soDH;  
}  
public int getmaKH() 
{  
    return maKH;  
}  
public void setmaKH(int maKH) 
{  
    this.maKH = maKH;  
}  
public double gettriGia() 
{  
    return triGia;  
}  
public void settriGia(double triGia) 
{  
    this.triGia = triGia;  
}      
public boolean gettinhTrang()
{
    return tinhTrang;
}
public void settinhTrang(boolean tinhTrang)
{
    this.tinhTrang = tinhTrang;
}

}
這是錯誤消息:

Caused by: org.hibernate.exception.DataException: could not execute statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:52) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java :42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) at org.hibernate. engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3171) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister. java:3686)在 org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.882 13246945888:90) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478) at org.hibernate.event.internal .AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454)...還有 9 個

Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'tinhTrang' at row 1 at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104) at com.mysql.cj .jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:974) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1113) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061) at com.mysql. cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1381) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1046) at org.8839 8379930688.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)... 17 更多

錯誤來源於MySQL服務器。 您正試圖將太大的值放入其中一列。

您應該檢查要添加到該列的值並將該列的類型更改為更大的值。

為了獲得更好的答案,您需要提供有關您嘗試向每一列添加哪些數據的更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM