In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Hibernate reverse engineering
1.1.Conceptual model of CDM
Although T_Complain is used here, it is not recommended, because when the JavaBean class is generated later, the TComplain.java class is generated instead of Complain.java.
1.2. Physical model
1.3. generated entity classes and Hibernate mapping files
Complain.java
Package com.rk.tax.entity;import java.sql.Timestimport java.util.HashSet;import java.util.Set;import java.util.Map;import java.util.HashMap;/** * TComplain entity. @ author MyEclipse Persistence Tools * / public class Complain implements java.io.Serializable {/ / Fields private String compId; private String compCompany; private String compName; private String compMobile; private Boolean isAnonymous; private Timestamp compTime; private String compTitle; private String toCompName; private String toCompDept; private String compContent; private String state; private Set complainreplies = new HashSet (0) / / status public static String COMPLAIN_STATE_UNDONE = "0"; public static String COMPLAIN_STATE_DONE = "1"; public static String COMPLAIN_STATE_INVALID = "2"; public static Map COMPLAIN_STATE_MAP; static {COMPLAIN_STATE_MAP = new HashMap (); COMPLAIN_STATE_MAP.put (COMPLAIN_STATE_UNDONE, "pending") COMPLAIN_STATE_MAP.put (COMPLAIN_STATE_DONE, "accepted"); COMPLAIN_STATE_MAP.put (COMPLAIN_STATE_INVALID, "invalid");} / / Constructors / * * default constructor * / public Complain () {} public String getCompId () {return compId } public void setCompId (String compId) {this.compId = compId;} public String getCompCompany () {return compCompany;} public void setCompCompany (String compCompany) {this.compCompany = compCompany;} public String getCompName () {return compName } public void setCompName (String compName) {this.compName = compName;} public String getCompMobile () {return compMobile;} public void setCompMobile (String compMobile) {this.compMobile = compMobile;} public Boolean getIsAnonymous () {return isAnonymous } public void setIsAnonymous (Boolean isAnonymous) {this.isAnonymous = isAnonymous;} public Timestamp getCompTime () {return compTime;} public void setCompTime (Timestamp compTime) {this.compTime = compTime;} public String getCompTitle () {return compTitle } public void setCompTitle (String compTitle) {this.compTitle = compTitle;} public String getToCompName () {return toCompName;} public void setToCompName (String toCompName) {this.toCompName = toCompName;} public String getToCompDept () {return toCompDept } public void setToCompDept (String toCompDept) {this.toCompDept = toCompDept;} public String getCompContent () {return compContent;} public void setCompContent (String compContent) {this.compContent = compContent;} public String getState () {return state } public void setState (String state) {this.state = state;} public Set getComplainreplies () {return complainreplies;} public void setComplainreplies (Set complainreplies) {this.complainreplies = complainreplies;}}
Knowledge points (1):
/ / status public static String COMPLAIN_STATE_UNDONE = "0"; public static String COMPLAIN_STATE_DONE = "1"; public static String COMPLAIN_STATE_INVALID = "2"; public static Map COMPLAIN_STATE_MAP; static {COMPLAIN_STATE_MAP = new HashMap (); COMPLAIN_STATE_MAP.put (COMPLAIN_STATE_UNDONE, "pending") COMPLAIN_STATE_MAP.put (COMPLAIN_STATE_DONE, "accepted"); COMPLAIN_STATE_MAP.put (COMPLAIN_STATE_INVALID, "invalid");}
Complain.hbm.xml
Note: remove the catalog= "database name" from the generated mapping file.
Knowledge points (1):
Knowledge points (2):
Knowledge points (3):
Corresponding class field
Private Boolean isAnonymous; private Timestamp compTime; private String compContent
Knowledge points (4):
Among them
Lazy= "false" cascade= "save-update" order-by= "reply_time"
Lazy= "false" means not to use lazy loading
Cascade= "save-update" means cascaded save, update
Order-by= "reply-time" means that the data taken out is sorted by reply-time. Note: reply_time is the name of the column of the database, and the field replyTime of the class can also be used here, but compared with the column name reply_time of the database, the field replyTime of the class may have problems in some versions, and the column name reply_time of the database is more universal.
Alternatively, you can sort the reply-time, such as using order-by= "reply-time desc", whose default value is asc, which can be omitted.
Complainreply.java
Package com.rk.tax.entity;import java.sql.Timest/** * TComplainreply entity. @ author MyEclipse Persistence Tools * / public class Complainreply implements java.io.Serializable {/ / Fields private String replyId; private Complain complain; private String replyer; private String replyDept; private Timestamp replyTime; private String replyContent / / Constructors / * * default constructor * / public Complainreply () {} / * * minimal constructor * / public Complainreply (Complain complain) {this.complain = complain } / * * full constructor * / public Complainreply (Complain complain, String replyer, String replyDept, Timestamp replyTime, String replyContent) {this.complain = complain; this.replyer = replyer; this.replyDept = replyDept; this.replyTime = replyTime; this.replyContent = replyContent } public String getReplyId () {return replyId;} public void setReplyId (String replyId) {this.replyId = replyId;} public Complain getComplain () {return complain;} public void setComplain (Complain complain) {this.complain = complain } public String getReplyer () {return replyer;} public void setReplyer (String replyer) {this.replyer = replyer;} public String getReplyDept () {return replyDept;} public void setReplyDept (String replyDept) {this.replyDept = replyDept } public Timestamp getReplyTime () {return replyTime;} public void setReplyTime (Timestamp replyTime) {this.replyTime = replyTime;} public String getReplyContent () {return replyContent;} public void setReplyContent (String replyContent) {this.replyContent = replyContent;}}
Complainreply.hbm.xml
Note: remove the catalog= "database name" from the generated mapping file.
2. From dao to action
Dao- > service- > action- > config
2.1Tier of dao
ComplainDao.java
Package com.rk.tax.dao;import com.rk.core.dao.BaseDao;import com.rk.tax.entity.Complain;public interface ComplainDao extends BaseDao {}
ComplainDaoImpl.java
Package com.rk.tax.dao.impl;import com.rk.core.dao.impl.BaseDaoImpl;import com.rk.tax.dao.ComplainDao;import com.rk.tax.entity.Complain;public class ComplainDaoImpl extends BaseDaoImpl implements ComplainDao {}
2.2, service layer
ComplainService.java
Package com.rk.tax.service;import com.rk.core.service.BaseService;import com.rk.tax.entity.Complain;public interface ComplainService extends BaseService {}
ComplainServiceImpl.java
Package com.rk.tax.service.impl;import java.util.Calendar;import java.util.List;import javax.annotation.Resource;import org.springframework.stereotype.Service;import com.rk.core.service.Impl.BaseServiceImpl;import com.rk.core.utils.QueryHelper;import com.rk.tax.dao.ComplainDao;import com.rk.tax.entity.Complain;import com.rk.tax.service.ComplainService;@Service ("complainService") public class ComplainServiceImpl extends BaseServiceImpl implements ComplainService {private ComplainDao complainDao @ Resource public void setComplainDao (ComplainDao complainDao) {setBaseDao (complainDao); this.complainDao = complainDao;}}
2.3.The action layer
ComplainAction.java
Package com.rk.tax.action;import java.net.URLDecoder;import java.sql.Timestimport java.util.Date;import javax.annotation.Resource;import org.apache.commons.lang3.StringUtils;import org.apache.commons.lang3.time.DateUtils;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Controller;import com.opensymphony.xwork2.ActionContext;import com.rk.core.action.BaseAction;import com.rk.core.utils.QueryHelper;import com.rk.tax.entity.Complain Import com.rk.tax.entity.Complainreply;import com.rk.tax.service.ComplainService;@Controller ("complainAction") @ Scope ("prototype") public class ComplainAction extends BaseAction {/ * 1, Business data * / private Complain complain; private String startTime; private String endTime; private String state; private Complainreply reply / * 2, business implementation class * / @ Resource private ComplainService complainService; / * 3, response page operation * / / list public String listUI () {/ / load status set ActionContext.getContext () .getContextMap () .put ("complainStateMap", Complain.COMPLAIN_STATE_MAP) Try {QueryHelper queryHelper = new QueryHelper (Complain.class, "c"); if (StringUtils.isNotBlank (startTime)) {/ / complaint data after query start time startTime = URLDecoder.decode (startTime, "utf-8") QueryHelper.addCondition ("c.compTime > =?", DateUtils.parseDate (startTime+ ": 00", "yyyy-MM-dd HH:mm:ss")) } if (StringUtils.isNotBlank (endTime)) {/ / complaint data before query end time endTime = URLDecoder.decode (endTime, "utf-8"); queryHelper.addCondition ("c.compTime-
Knowledge points (2):
DealUI.jsp
Complaint acceptance management complaint acceptance management-complaint acceptance details (accepted) whether the complainant information is anonymous complaint: complaint unit: Name of the complainant: The complainant's mobile phone: Complaint information complaint time: complaint department: complainee: complaint title: Content of complaint: reply to accepted information Reply department: reply person: reply time: Accept the operation response department: Reply: reply: 10 ">
Knowledge points (2):
Knowledge point (3): different from the support for OGNL
Knowledge points (4): escape
Content of complaint:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.