Eclipse开发环境Hibernate持久层数据库存取测试(3

以上设置为开发前的预配置。下面为Eclipse开发过程中的类及文件的创建和配置。

首先创建一个新的项目。如果是新建了一个WEB Project, 可以SRC下,设置你所要的包名。此处简化为mypackage.

在这个包名下,创建一个你用以施行持久层测试的测试类,我们把它命名为:ORMService.java ,在此之前,你可

以先创建基于数据库中temp 表的Temp.java类。 Temp.java的代码如下:

/*

 * Created on 2005-7-27

 *本类用以对MYSQL数据库的测试

 *持久层组件为Hibernate

 */

package com.learndiary.website.module.beans;

import java.io.Serializable;

/**

 * @author binglian

 *本类的hbm映射文件为:Temp.hbm

 */

public class Temp implements Serializable{

private Long id;

private String name;

private String value;

private String description;

public Temp(){

}

public Temp( String Vname, String Vvalue, String Vdescription){

this.name = Vname;

this.value =Vvalue;

this.description = Vdescription;

}

/**

* @return Returns the description.

*/

public String getDescription() {

return description;

}

/**

* @param description The description to set.

*/

public void setDescription(String description) {

this.description = description;

}

/**

* @return Returns the id.

*/

public Long getId() {

return id;

}

/**

* @param id The id to set.

*/

public void setId(Long id) {

this.id = id;

}

/**

* @return Returns the name.

*/

public String getName() {

return name;

}

/**

* @param name The name to set.

*/

public void setName(String name) {

this.name = name;

}

/**

* @return Returns the value.

*/

public String getValue() {

return value;

}

/**

* @param value The value to set.

*/

public void setValue(String value) {

this.value = value;

}

}

Author: lian

努力奋斗中...