81,095
社区成员
发帖
与我相关
我的任务
分享
Session session = HibernateSessionFactory.getSession();
Transaction tran = session.beginTransaction();
Speak s = (Speak)session.get(Speak.class, 1);
System.out.println("at:"+s.getAttachmentFlag());
tran.commit();
session.close();
return "success";
<property name="attachmentFlag" type="java.lang.String">
<column name="attachment_flag" length="20"></column>
</property>
-- Table "speak" DDL
CREATE TABLE `speak` (
`speak_id` int(11) NOT NULL auto_increment,
`user_id` int(11) default NULL,
`content` mediumtext,
`create_time` timestamp NULL default NULL on update CURRENT_TIMESTAMP,
`last_comm_time` timestamp NULL default NULL COMMENT '后评论最时间',
`cate_flag` varchar(50) default NULL COMMENT 'twitter,style,topic',
`x_id` int(11) default NULL COMMENT '现表示的是forum的id',
`attachment_flag` varchar(20) default '0' ,
`comment_sum` int(11) default '0' COMMENT '应相的speak被评论的次数',
`love_sum` int(11) default '0' COMMENT '对应的speak被喜欢的次数',
`forward_sum` int(11) default '0' COMMENT '对应的speak被转发的次数',
PRIMARY KEY (`speak_id`),
KEY `user_id` (`user_id`),
KEY `love_sum` (`love_sum`),
KEY `cate_flag` (`cate_flag`),
KEY `attachment_flag` (`attachment_flag`),
CONSTRAINT `speak_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
package com.shaiyaya.dao;
import java.util.Date;
/**
* Speak entity.
*
* @author MyEclipse Persistence Tools
*/
public class Speak implements java.io.Serializable {
// Fields
private Integer speakId;
private User user;
private String content;
private Date createTime;
private Date lastCommTime;
private String cateFlag;
private Integer XId;
private String attachmentFlag;
private Integer commentSum;
private Integer loveSum;
private Integer forwardSum;
// Constructors
/** default constructor */
public Speak() {
}
/** full constructor */
public Speak(User user, String content, Date createTime, Date lastCommTime,
String cateFlag, Integer XId, String attachmentFlag,
Integer commentSum, Integer loveSum, Integer forwardSum) {
this.user = user;
this.content = content;
this.createTime = createTime;
this.lastCommTime = lastCommTime;
this.cateFlag = cateFlag;
this.XId = XId;
this.attachmentFlag = attachmentFlag;
this.commentSum = commentSum;
this.loveSum = loveSum;
this.forwardSum = forwardSum;
}
// Property accessors
public Integer getSpeakId() {
return this.speakId;
}
public void setSpeakId(Integer speakId) {
this.speakId = speakId;
}
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
public String getContent() {
return this.content;
}
public void setContent(String content) {
this.content = content;
}
public Date getCreateTime() {
return this.createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getLastCommTime() {
return this.lastCommTime;
}
public void setLastCommTime(Date lastCommTime) {
this.lastCommTime = lastCommTime;
}
public String getCateFlag() {
return this.cateFlag;
}
public void setCateFlag(String cateFlag) {
this.cateFlag = cateFlag;
}
public Integer getXId() {
return this.XId;
}
public void setXId(Integer XId) {
this.XId = XId;
}
public String getAttachmentFlag() {
return this.attachmentFlag;
}
public void setAttachmentFlag(String attachmentFlag) {
this.attachmentFlag = attachmentFlag;
}
public Integer getCommentSum() {
return this.commentSum;
}
public void setCommentSum(Integer commentSum) {
this.commentSum = commentSum;
}
public Integer getLoveSum() {
return this.loveSum;
}
public void setLoveSum(Integer loveSum) {
this.loveSum = loveSum;
}
public Integer getForwardSum() {
return this.forwardSum;
}
public void setForwardSum(Integer forwardSum) {
this.forwardSum = forwardSum;
}