Dear
JBoss 4.0.4 GA with EJB 3.0
MySQL 4.1.4, database's character set is euckr
I've installed the JBoss 4.0.4 GA with EJB3 with installer.
There is an bug with dealing with @Lob annotation column in the Mysql 4.1.4.
The column datatype is
text in the mysql, so I've used @Lob annotation.
If the column data has I18N character(Korean for me), the column datas are cutting it off.
BUT if the column data has only english character and numeric character, it's OK.
EntityBean's code is below.
Code:
package com.javamodeling.homepage.board;
import java.util.Collection;
import java.util.Iterator;
import javax.ejb.Remove;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.hibernate.LazyInitializationException;
import com.javamodeling.homepage.common.AbstractResultValue;
import com.javamodeling.homepage.ejb.JmcMember;
import com.javamodeling.util.DateUtils;
@Entity
@Table(name = "JAVAMODELING_BOARD")
@TableGenerator(name = "IdGen",
table = "ID_GENERATOR",
pkColumnName = "ID_NO",
pkColumnValue = "1",
valueColumnName = "NEXT_VALUE",
allocationSize = 1)
public class Board extends AbstractResultValue {
private Integer boardSeq;
private Character noticeYn;
private Integer groupNo;
private Integer groupIndex;
private Integer levelDepth;
private String subject;
private String contents;
private String referer;
private Integer viewCount;
private Integer childReplyCount;
private Character deleteYn;
private Integer memberNo;
private String inputDate;
private String updateDate;
private Integer parentBoardSeq;
private Integer listSeq;
private Board parentBoard;
private BoardList boardList;
// ???? ??? ?? ??
private JmcMember jmcMember;
private Collection<BoardFile> boardFiles;
private Collection<Board> childBoards;
public Board() {
}
@Override
public void reset() {
}
@Column(name = "LIST_SEQ")
public Integer getListSeq() {
return listSeq;
}
public void setListSeq(Integer listSeq) {
this.listSeq = listSeq;
}
@Column(name = "BOARD_SEQ")
@Id @GeneratedValue(strategy=GenerationType.TABLE, generator="IdGen")
public Integer getBoardSeq() {
return boardSeq;
}
public void setBoardSeq(Integer boardSeq) {
this.boardSeq = boardSeq;
}
@Column(name = "CHILD_REPLY_COUNT")
public Integer getChildReplyCount() {
return childReplyCount;
}
public void setChildReplyCount(Integer childReplyCount) {
this.childReplyCount = childReplyCount;
}
@Column(name = "CONTENTS")
@Lob
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
@Column(name = "DELETE_YN")
public Character getDeleteYn() {
return deleteYn;
}
public void setDeleteYn(Character deleteYn) {
this.deleteYn = deleteYn;
}
@Column(name = "GROUP_INDEX")
public Integer getGroupIndex() {
return groupIndex;
}
public void setGroupIndex(Integer groupIndex) {
this.groupIndex = groupIndex;
}
@Column(name = "GROUP_NO")
public Integer getGroupNo() {
return groupNo;
}
public void setGroupNo(Integer groupNo) {
this.groupNo = groupNo;
}
@Column(name = "INPUT_DATE")
public String getInputDate() {
return inputDate;
}
public void setInputDate(String inputDate) {
this.inputDate = inputDate;
}
@Column(name = "MEMBER_NO")
public Integer getMemberNo() {
return memberNo;
}
public void setMemberNo(Integer memberNo) {
this.memberNo = memberNo;
}
@Column(name = "LEVEL_DEPTH")
public Integer getLevelDepth() {
return levelDepth;
}
public void setLevelDepth(Integer levelDepth) {
this.levelDepth = levelDepth;
}
@Column(name = "NOTICE_YN")
public Character getNoticeYn() {
return noticeYn;
}
public void setNoticeYn(Character noticeYn) {
this.noticeYn = noticeYn;
}
@Column(name = "PARENT_BOARD_SEQ")
public Integer getParentBoardSeq() {
return parentBoardSeq;
}
public void setParentBoardSeq(Integer parentBoardSeq) {
this.parentBoardSeq = parentBoardSeq;
}
@Column(name = "REFERER")
public String getReferer() {
return referer;
}
public void setReferer(String referer) {
this.referer = referer;
}
@Column(name = "SUBJECT")
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
@Column(name = "UPDATE_DATE")
public String getUpdateDate() {
return updateDate;
}
public void setUpdateDate(String updateDate) {
this.updateDate = updateDate;
}
@Column(name = "VIEW_COUNT")
public Integer getViewCount() {
return viewCount;
}
public void setViewCount(Integer viewCount) {
this.viewCount = viewCount;
}
@ManyToOne
@JoinColumn(name = "LIST_SEQ", insertable = false, updatable = false)
public BoardList getBoardList() {
return boardList;
}
public void setBoardList(BoardList boardList) {
this.boardList = boardList;
}
@ManyToOne
@JoinColumn(name = "PARENT_BOARD_SEQ", insertable = false, updatable = false)
public Board getParentBoard() {
return parentBoard;
}
public void setParentBoard(Board parentBoard) {
this.parentBoard = parentBoard;
}
@ManyToOne
@JoinColumn(name = "MEMBER_NO", insertable = false, updatable = false)
public JmcMember getJmcMember() {
return jmcMember;
}
public void setJmcMember(JmcMember jmcMember) {
this.jmcMember = jmcMember;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parentBoard")
public Collection<Board> getChildBoards() {
return childBoards;
}
public void setChildBoards(Collection<Board> childBoards) {
this.childBoards = childBoards;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "board")
public Collection<BoardFile> getBoardFiles() {
return boardFiles;
}
public void setBoardFiles(Collection<BoardFile> boardFiles) {
this.boardFiles = boardFiles;
}
and after call a methods as below,
When the modify the data of any column, the data of CONTENTS column is cut off.
The data of the column with has only @Lob annotation(text datatype) is cutting off
Code:
public Board searchOneWithOneLevel(Integer boardSeq) {
Board board = null;
try {
board = entityManager.find(Board.class, boardSeq);
board.setViewCount(board.getViewCount() + 1);
entityManager.flush();
board.setResultCode(new Integer(1));
board.setResultMessage(BoardBundle.getString("Success.Search"));
} catch (EntityNotFoundException e) {
logger.error(e.getMessage());
board = new Board();
board.setResultCode(new Integer(-1));
board.setResultMessage(BoardBundle.getString("Error.EntityNotFoundException"));
}
return board;
}
This is a VERY SERIOUS problem for me.
I can not modify the data.
# Ritchie