eclipse已经自带了xdoclet,而且已经有了它的各项支持模板。
具体的操作很简单
1.新建一个user.java 配置好相关的属性
package com.jy.vo;
/** * @hibernate.class * table="USER" */ public class user { private Integer id; private String name; private String password;
/** * @hibernate.id * column="ID" * unsaved-value="null" * generator-class="increment" */ public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; } /** * @hibernate.property * column="NAME" * length="15" * unsaved-value="null" * update="false" */ public String getName() { return name; }
public void setName(String name) { this.name = name; } /** * @hibernate.property * column="PASSWORD" * length="15" * unsaved-value="null" * update="false" */ public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; } }
|
2.点击工程根目录点击属性,选择Myeclipse-xdoclet---->add standart--->standard hibernate,选择OK
3.再选择工程myclipse--->run xdoclet 直接生成user.hbm.xml,完成
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "">
<hibernate-mapping > <class name="com.jy.vo.user" table="USER" >
<id name="id" column="ID" type="java.lang.Integer" unsaved-value="null" > <generator class="increment"> <!-- To add non XDoclet generator parameters, create a file named hibernate-generator-params-user.xml containing the additional parameters and place it in your merge dir. --> </generator> </id>
<property name="name" type="java.lang.String" column="NAME" length="15" />
<property name="password" type="java.lang.String" column="PASSWORD" length="15" />
<!-- To add non XDoclet property mappings, create a file named hibernate-properties-user.xml containing the additional properties and place it in your merge dir. -->
</class>
</hibernate-mapping>
|
配置standard hibernate的时候会生成hibernatedoclet节点,要注意的是配置好要映射的实体类的路径,和hibernate的版本,如果没报错又什么都没生成就好好检查一下路径和版本吧:)
阅读(800) | 评论(1) | 转发(0) |