這是異常消息我得到:的PersistenceException:行大小太大
[java] Exception in thread "main" javax.ejb.EJBException: The bean encountered a non-application exception; nested exception is:
[java] javax.ejb.EJBTransactionRolledbackException: The transaction has been marked rollback only because the bean encountered a non-application exception :org.apache.openjpa.persistence.PersistenceException : Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs {stmnt 23775157 CREATE TABLE comment (comment_id INTEGER NOT NULL AUTO_INCREMENT, comment_content VARCHAR(65535) NOT NULL, comment_date DATETIME NOT NULL, comment_title VARCHAR(65535) NOT NULL, user_id INTEGER NOT NULL, post_id INTEGER NOT NULL, PRIMARY KEY (comment_id), UNIQUE U_COMMENT_COMMENT_ID (comment_id)) ENGINE = innodb} [code=1118, state=42000]
這是Comment
類(的一部分):
@Entity
@Table(name = "comment")
public class Comment implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "comment_id", unique = true, nullable = false)
private Integer id;
@Column(name = "comment_title", length=65535, unique = false, nullable = false)
private String title;
@Column(name = "comment_date", unique = false, nullable = false)
private Date date;
@Column(name = "comment_content", length=65535, unique = false, nullable = false)
private String content;
@ManyToOne
@JoinColumn (name = "user_id", referencedColumnName="user_id", nullable = false)
private User user;
@ManyToOne
@JoinColumn (name = "post_id", referencedColumnName="post_id", nullable = false)
private Post post;
// ... getters and setters
}
我有這個代碼上面的註釋工作,並且我正在數據庫中生成表。說實話,可能是,我已經搞混了一些關於導入罐子項目(不知道)。我沒有更改代碼,這是肯定的,但我不知道如何解決這個問題。感謝任何幫助。
好的,我爲每個長度爲65535的字符串字段添加了'columnDefinition =「TEXT」',並且我在數據庫中獲取映射表,並且這些字符串字段是'TEXT' mysql類型。但是,如果沒有明確定義'columnDefinition =「TEXT」',爲什麼它不工作?不應該創建'varchar(65535)'類型的字段嗎? – Vladimir