Hibernate使用xdoclet生成映射文件和sql语句

使用Hibernate的集成工具xdoclet生成映射文件和sql语句的步骤和代码:

1、编写java代码

public class BmsOrderPayment implements Serializable {

	/**
	 **/
	private static final long serialVersionUID = 7612212313354109083L;
	
	private String id;
	private String orderId;
	private String tradeSerialNumber;
	private Integer paymentState;//付款状态
	private Long paymentTime;//付款时间
	private String payerUserId;
	private String payerBankCode;
	private String payerBankType;
	private Integer paymentMutiFlag;
	private String remark;
	private String remark1;
	private String remark2;
	
	
	/**
	 * 
	 *<p>Title:空的构造函数<p>
	 *<p>Description:<p>
	 *
	 */
	public BmsOrderPayment() {
		super();
	}
	
	
	/**
	 * 
	 *<p>Title:带参数的构造函数<p>
	 *<p>Description:<p>
	 *@param id
	 *@param orderId
	 *@param tradeSerialNumber
	 *@param paymentState
	 *@param paymentTime
	 *@param payerUserId
	 *@param payerBankCode
	 *@param payerBankType
	 *@param paymentMutiFlag
	 *@param remark
	 *@param remark1
	 *@param remark2
	 *
	 */
	public BmsOrderPayment(String id, String orderId, String tradeSerialNumber,
			Integer paymentState, Long paymentTime, String payerUserId,
			String payerBankCode, String payerBankType,
			Integer paymentMutiFlag, String remark, String remark1,
			String remark2) {
		super();
		this.id = id;
		this.orderId = orderId;
		this.tradeSerialNumber = tradeSerialNumber;
		this.paymentState = paymentState;
		this.paymentTime = paymentTime;
		this.payerUserId = payerUserId;
		this.payerBankCode = payerBankCode;
		this.payerBankType = payerBankType;
		this.paymentMutiFlag = paymentMutiFlag;
		this.remark = remark;
		this.remark1 = remark1;
		this.remark2 = remark2;
	}



	//----------------- start setter getter -----------------	
	/**
     * @hibernate.id generator-class="uuid" column="ID"
     * @hibernate.meta attribute="field-description" value="标识"
     */
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	/**
	 * @hibernate.property column="Order_ID"
	 * @hibernate.meta attribute="field-description" value="订单Id"
	 */
	public String getOrderId() {
		return orderId;
	}
	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}
	/**
	 * @hibernate.property column="Trade_Serial_Number"
	 * @hibernate.meta attribute="field-description" value="支付流水号"
	 */
	public String getTradeSerialNumber() {
		return tradeSerialNumber;
	}
	public void setTradeSerialNumber(String tradeSerialNumber) {
		this.tradeSerialNumber = tradeSerialNumber;
	}
	
	/**
	 * @hibernate.property column="Payment_State"
	 * @hibernate.meta attribute="field-description" value="付款状态"
	 */
	public Integer getPaymentState() {
		return paymentState;
	}
	public void setPaymentState(Integer paymentState) {
		this.paymentState = paymentState;
	}
	/**
	 * @hibernate.property column="Payment_Time"
	 * @hibernate.meta attribute="field-description" value="付款时间"
	 */
	public Long getPaymentTime() {
		return paymentTime;
	}
	public void setPaymentTime(Long paymentTime) {
		this.paymentTime = paymentTime;
	}
	
	/**
	 * @hibernate.property column="Payer_User_Id"
	 * @hibernate.meta attribute="field-description" value="付款人id"
	 */
	public String getPayerUserId() {
		return payerUserId;
	}
	public void setPayerUserId(String payerUserId) {
		this.payerUserId = payerUserId;
	}
	/**
	 * @hibernate.property column="Payer_Bank_Code"
	 * @hibernate.meta attribute="field-description" value="付款银行编码"
	 */
	public String getPayerBankCode() {
		return payerBankCode;
	}
	public void setPayerBankCode(String payerBankCode) {
		this.payerBankCode = payerBankCode;
	}
	/**
	 * @hibernate.property column="Payer_Bank_Type"
	 * @hibernate.meta attribute="field-description" value="付款银行类别"
	 */
	public String getPayerBankType() {
		return payerBankType;
	}
	public void setPayerBankType(String payerBankType) {
		this.payerBankType = payerBankType;
	}
	/**
	 * @hibernate.property column="Payment_Muti_Flag"
	 * @hibernate.meta attribute="field-description" value="支付多次标识"
	 */
	public Integer getPaymentMutiFlag() {
		return paymentMutiFlag;
	}
	public void setPaymentMutiFlag(Integer paymentMutiFlag) {
		this.paymentMutiFlag = paymentMutiFlag;
	}
	/**
	 * @hibernate.property column="Remark"
	 * @hibernate.meta attribute="field-description" value="备注字段"
	 */
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	/**
	 * @hibernate.property column="Remark1"
	 * @hibernate.meta attribute="field-description" value="备注字段1"
	 */
	public String getRemark1() {
		return remark1;
	}
	public void setRemark1(String remark1) {
		this.remark1 = remark1;
	}
	/**
	 * @hibernate.property column="Remark2"
	 * @hibernate.meta attribute="field-description" value="备注字段2"
	 */
	public String getRemark2() {
		return remark2;
	}
	public void setRemark2(String remark2) {
		this.remark2 = remark2;
	}
//-----------------end  setter getter end-----------------	

}

 注意代码中getter方法上的注释代码。

2、在项目中导入xdoclet需要的jar文件。参照附件

3、运行ant对应的target。其中ant的build.xml在附件中

你可能感兴趣的:(Hibernate)