`
hyj_dx
  • 浏览: 101542 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

webwork+hibernate+spring项目源代码自动生成(附源代码)

阅读更多

自己写了一个自动生成源代码的工具,代码自动生成,以及一个完整项目的成功实践,还在继续完善当中,采用freemaker配置模板,可以根据自己的需要生成自己想要的代码

 

先来看看怎么使用,很简单

先配置config.xml 配置设置模板路径,以及项目生成路径,可以自己定义

 

<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
 <code>
  <projectpath>D:/vobuilder/vobuilder</projectpath>
  
  <model>com.hyj.model</model>
  <action>com.hyj.action</action>
  <dao>com.hyj.dao</dao>
  <daoimpl>com.hyj.dao.jdbc</daoimpl>
  <service>com.hyj.service</service>
  <serviceimpl>com.hyj.service.impl</serviceimpl> 
  <jsp>/freemarker/jsp</jsp>
   
 </code>
</xml-body>

 

 

 

CodeGenerator cg = new CodeGenerator();
cg.generate("tableName");

//这样就生成了所有项目的文件

  

 

 1.生成代码的引擎

 

package com.hyj.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.sql.Connection;
import java.util.Map;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.szxhdz.util.Factory;

import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateException;

public abstract class AbstractEngine {

 protected static Logger logger = LogManager.getLogger(AbstractEngine.class);

 protected static Connection con;

 protected static Configuration cfg;

 public AbstractEngine(String templatePath) {
  con = Factory.getConnection();
  try {
   cfg = new Configuration();
   cfg.setDefaultEncoding("gb2312");
   cfg.setDirectoryForTemplateLoading(new File(templatePath));
   cfg.setObjectWrapper(new DefaultObjectWrapper());
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public static void create(String ftlTemplate, Map contents, String savePath,
   String saveFilename) {
  try {
   Template temp = cfg.getTemplate(ftlTemplate);
   logger.info("generate file " + saveFilename + "  in path "
     + savePath);
   File file = new File(savePath);
   if (!file.exists()) {
    file.mkdirs();
   }
   Writer out = new OutputStreamWriter(new FileOutputStream(savePath
     + "/" + saveFilename), "gb2312");
   temp.process(contents, out);
   out.flush();
  } catch (IOException e) {
   e.printStackTrace();
  } catch (TemplateException e1) {
   e1.printStackTrace();
  }
 }
}

 

2。生成代码的实现类

 

package com.hyj.util;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.hyj.util.JDBCUtil.Column;
import com.szxhdz.util.SystemConstant;

public class CodeGenerator extends AbstractEngine implements Creater{
	private static final String BASE_PATH = SystemConstant.getProperty("code.projectpath");

	private static final String PACKAGE_PATH = "/src/com/hyj/";

	private static final String JAVA_CODE_GENERATOR_PATH = BASE_PATH
			+ PACKAGE_PATH;

	private static final String TEMPLATE_PATH = BASE_PATH
			+ "/freemarker/template";

	public CodeGenerator() {
		super(TEMPLATE_PATH);
	}

	public CodeGenerator(String templatePath) {
		super(templatePath);
	}

	public void generatorJSP(String table) {
		try {
			List priList = JDBCUtil
			.getPrimaryKeyColumns(con, null, null, table);
			Column pk = (Column) priList.get(0);
			Map params = new HashMap();
			params.put("table", table);
			params.put("columnList", JDBCUtil.getTableColumns(con, null, null,
					table));
			params.put("pk", pk);
			create("add.ftl", params, BASE_PATH + "/freemarker/jsp", table
					.toLowerCase().replaceAll("_", "")
					+ "_add.jsp");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generaorAll() {
		List tbList = null;
		try {
			tbList = JDBCUtil.getTables(con, null, "FTFJ_WEB", null);
			for (Iterator iter = tbList.iterator(); iter.hasNext();) {
				String table = (String) iter.next();
				generatorJSP(table);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void generateModel(String table) {
		try {
			Map params = new HashMap();
			params.put("table", table);
			params.put("columnList", JDBCUtil.getTableColumns(con, null, null,
					table));
			create("bean.ftl", params, JAVA_CODE_GENERATOR_PATH + "model",
					table.substring(0, 1).toUpperCase()
							+ table.toLowerCase().replaceAll("_", "")
									.substring(1) + ".java");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generatorModels() {
		List tbList = null;
		try {
			tbList = JDBCUtil.getTables(con, null, "FTFJ_WEB", null);
			for (Iterator iter = tbList.iterator(); iter.hasNext();) {
				String table = (String) iter.next();
				generateModel(table);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void generateDao(String tableName) {
		try {
			List priList = JDBCUtil
					.getPrimaryKeyColumns(con, null, null, tableName);
			Column pk = (Column) priList.get(0);
			Map params = new HashMap();
			params.put("tableName", tableName);
			params.put("columnList", JDBCUtil.getTableColumns(con, null, null,
					tableName));
			params.put("pk", pk);
			create("dao.ftl", params, BASE_PATH +"/src/"+ SystemConstant.getProperty("code.dao").replace(".","/"),"I"+ tableName
					.substring(0, 1).toUpperCase()
					+ tableName.substring(1,tableName.length()).toLowerCase()
							.replaceAll("_", "") + "Dao.java");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void generateDaoImpl(String table) {
		try {
			List priList = JDBCUtil
					.getPrimaryKeyColumns(con, null, null, table);
			Column pk = (Column) priList.get(0);
			Map params = new HashMap();
			params.put("table", table);
			params.put("columnList", JDBCUtil.getTableColumns(con, null, null,
					table));
			params.put("pk", pk);
			create("daoimpl.ftl", params, JAVA_CODE_GENERATOR_PATH + "dao/jdbc", table
					.substring(0, 1).toUpperCase()
					+ table.substring(1, table.length()).toLowerCase()
							.replaceAll("_", "") + "Dao.java");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generateSql() {

		List tbList = null;
		List ls = new ArrayList();
		try {
			tbList = JDBCUtil.getTables(con, null, null, null);
			Map params = new HashMap();

			for (Iterator iter = tbList.iterator(); iter.hasNext();) {
				String table = (String) iter.next();
				List columnlist = JDBCUtil.getTableColumns(con, null, null,
						table);
				Column pk = (Column) JDBCUtil.getPrimaryKeyColumns(con, null,
						null, table).get(0);
				SqlBean sqlbean = new SqlBean();
				sqlbean.setColumnList(columnlist);
				sqlbean.setPk(pk);
				sqlbean.setTable(table);
				ls.add(sqlbean);
			}
			params.put("ls", ls);
			create("db.ftl", params, JAVA_CODE_GENERATOR_PATH + "sql", "db.sql");
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public void generateAction(String table) {
		try {

			Map params = new HashMap();

			List columnlist = JDBCUtil.getTableColumns(con, null, null, table);
			params.put("columnlist", columnlist);
			params.put("table", table);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,
					table).get(0));
			create("action.ftl", params, JAVA_CODE_GENERATOR_PATH + "action",
					table.substring(0, 1).toUpperCase()
							+ table.substring(1).toLowerCase().replaceAll("_",
									"") + "Action.java");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generateList(String table) {
		try {

			Map params = new HashMap();

			List columnlist = JDBCUtil.getTableColumns(con, null, null, table);
			params.put("columnlist", columnlist);
			params.put("table", table);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,
					table).get(0));
			create("list.ftl", params, BASE_PATH + "/freemarker/jsp", table
					.toLowerCase().replaceAll("_", "")
					+ "_list.jsp");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generateXwork(String table) {
		try {

			Map params = new HashMap();

			List columnlist = JDBCUtil.getTableColumns(con, null, null, table);
			params.put("columnlist", columnlist);
			params.put("table", table);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,
					table).get(0));
			create("xwork.ftl", params, JAVA_CODE_GENERATOR_PATH, "xwork-"
					+ table.toLowerCase().replaceAll("_", "") + ".xml");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generateApplicationContext() {
		List tbList = null;
		List tableList = new ArrayList();
		try {
			tbList = JDBCUtil.getTables(con, null, null, null);
			for (Iterator iter = tbList.iterator(); iter.hasNext();) {
				String table = (String) iter.next();
				tableList.add(table);
			}
			Map params = new HashMap();
			params.put("tableList", tableList);
			create("applicationContext.ftl", params, JAVA_CODE_GENERATOR_PATH,
					"applicationContext.xml");
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void generateValidation(String table) {
		try {
			Map params = new HashMap();
			List columnlist = JDBCUtil.getTableColumns(con, null, null, table);
			params.put("columnlist", columnlist);
			params.put("table", table);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,table).get(0));
			create("validation.ftl", params, JAVA_CODE_GENERATOR_PATH + "action",table.substring(0,1).toUpperCase()+table.substring(1).toLowerCase().replaceAll("_", "") + "Action-validation.xml");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void generateValidation_properties(String table) {
		try {
			Map params = new HashMap();
			List columnlist = JDBCUtil.getTableColumns(con, null, null, table);
			params.put("columnlist", columnlist);
			params.put("table", table);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,table).get(0));
			create("validation_properties.ftl", params, JAVA_CODE_GENERATOR_PATH + "action",table.substring(0,1).toUpperCase()+table.substring(1).toLowerCase().replaceAll("_", "") + "Action.properties");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	public void generateService(String tableName) {
		try {
			Map params = new HashMap();
			List columnlist = JDBCUtil.getTableColumns(con, null, null, tableName);
			params.put("columnlist", columnlist);
			params.put("tableName", tableName);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,tableName).get(0));
			create("service.ftl", params, BASE_PATH+"/src/" + SystemConstant.getProperty("code.service").replace(".","/"),"I"+tableName.substring(0,1).toUpperCase()+tableName.substring(1).toLowerCase().replaceAll("_", "") + "Service.java");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

	public void generateServiceImpl(String tableName) {
		try {
			Map params = new HashMap();
			List columnlist = JDBCUtil.getTableColumns(con, null, null, tableName);
			params.put("columnlist", columnlist);
			params.put("tableName", tableName);
			params.put("pk", JDBCUtil.getPrimaryKeyColumns(con, null, null,tableName).get(0));
			create("serviceimpl.ftl", params, BASE_PATH+"/src/" + SystemConstant.getProperty("code.serviceimpl").replace(".","/"),tableName.substring(0,1).toUpperCase()+tableName.substring(1).toLowerCase().replaceAll("_", "") + "Service.java");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	public void generate(String tableName){
		generateAction(tableName);
		generateApplicationContext();
		generateDao(tableName);
	    generateDaoImpl(tableName);
		generateList(tableName);
		generateModel(tableName);
		generateXwork(tableName);
		generatorJSP(tableName);
		generateValidation(tableName);
		generateValidation_properties(tableName);
		generateService(tableName);
		generateServiceImpl(tableName);
	}
	
	public static void main(String[] args) {
		CodeGenerator generator = new CodeGenerator();
	//	generator.generateDao("ADV_POSITION");
		//generator.generateAction("ADV_POSITION");
		generator.generatorJSP("ADV_POSITION");
	}

	

}

 

 3。下面是jdbc底层操作类

/*
 * JDBCUtil.java
 *
 * Created on November 9, 2002, 4:27 PM
 */

package com.hyj.util;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import net.sf.hibernate.Hibernate;
import net.sf.hibernate.type.NullableType;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author  Administrator
 */
public class JDBCUtil {
	private static final Log logger = LogFactory.getLog(JDBCUtil.class);
	public static class Column {
		public String name;
		public int sqlType;
		public int sqlColumnLength;
		public int sqlDecimalLength;
		public boolean sqlNotNull;
		public boolean sqlReadOnly;
		public NullableType hibernateType;
		public Class javaType;
		public String sqlTypeName;
		public String defalutValue;
		public boolean equals(Object o) {
			boolean rv = false;
			if (o != null && o instanceof JDBCUtil.Column) {
				rv = (name.equals(((JDBCUtil.Column)o).name));
			}
			return rv;
		}
		public int hashCode() {
			return (name != null) ? name.hashCode() : 0;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public NullableType getHibernateType() {
			return hibernateType;
		}
		public void setHibernateType(NullableType hibernateType) {
			this.hibernateType = hibernateType;
		}
		public Class getJavaType() {
			return javaType;
		}
		public void setJavaType(Class javaType) {
			this.javaType = javaType;
		}
		public int getSqlColumnLength() {
			return sqlColumnLength;
		}
		public void setSqlColumnLength(int sqlColumnLength) {
			this.sqlColumnLength = sqlColumnLength;
		}
		public int getSqlDecimalLength() {
			return sqlDecimalLength;
		}
		public void setSqlDecimalLength(int sqlDecimalLength) {
			this.sqlDecimalLength = sqlDecimalLength;
		}
		public boolean isSqlNotNull() {
			return sqlNotNull;
		}
		public void setSqlNotNull(boolean sqlNotNull) {
			this.sqlNotNull = sqlNotNull;
		}
		public boolean isSqlReadOnly() {
			return sqlReadOnly;
		}
		public void setSqlReadOnly(boolean sqlReadOnly) {
			this.sqlReadOnly = sqlReadOnly;
		}
		public int getSqlType() {
			return sqlType;
		}
		public void setSqlType(int sqlType) {
			this.sqlType = sqlType;
		}
		public String getSqlTypeName() {
			return sqlTypeName;
		}
		public void setSqlTypeName(String sqlTypeName) {
			this.sqlTypeName = sqlTypeName;
		}
		public String getDefalutValue() {
			return defalutValue;
		}
		public void setDefalutValue(String defalutValue) {
			this.defalutValue = defalutValue;
		}
		
		
	};
	
	public static List getCatalogs(Connection c) throws SQLException {
		DatabaseMetaData dmd = c.getMetaData();
		ResultSet rs = null;
		try {
			rs = dmd.getCatalogs();
			List l = new LinkedList();
			while (rs.next()) {
				l.add(rs.getString(1));
			}
			return l;
		}
		finally {
			if (rs != null) rs.close();
		}
	}
	
	public static Map getSchemas(Connection c) throws SQLException {
		DatabaseMetaData dmd = c.getMetaData();
		ResultSet rs = null;
		try {
			rs = dmd.getSchemas();
			Map map = new HashMap();
			List l;
			while (rs.next()) {
				String schema = rs.getString(1);
				String catalog = null;
				if (rs.getMetaData().getColumnCount() > 1) {
					catalog = rs.getString(2);
				};
				l = (List)map.get(catalog);
				if (l == null) {
					l = new LinkedList();
					map.put(catalog, l);
				}
				l.add(schema);
			}
			return map;
		}
		finally {
			if (rs != null) rs.close();
		}
	}
	
	public static List getTables(Connection c, String catalog, String schema, String tablePattern) throws SQLException {
		logger.debug("catalog='" + catalog + "'");
		logger.debug("schema='" + schema + "'");
		logger.debug("table='" + tablePattern + "'");
		DatabaseMetaData dmd = c.getMetaData();
		ResultSet rs = null;
		try {
			rs = dmd.getTables(catalog, schema, tablePattern, new String[] {"TABLE", "VIEW", "SYNONYM", "ALIAS"} );
			List l= new LinkedList();
			while (rs.next()) {
				l.add(rs.getString(3));
			}
			return l;
		}
		finally {
			if (rs != null) rs.close();
		}
	}
	
	public static Set getForeignKeyColumns(Connection c, String catalog, String schema, String table) throws SQLException {
		logger.debug("catalog='" + catalog + "'");
		logger.debug("schema='" + schema + "'");
		logger.debug("table='" + table + "'");
		DatabaseMetaData dmd = c.getMetaData();
		ResultSet rs = null;
		try {
			rs = dmd.getImportedKeys(catalog, schema, table);
			HashSet columns = new HashSet();
			while (rs.next()) {
				columns.add(rs.getString(8));
			}
			return columns;
		}
		finally {
			if (rs != null) rs.close();
		}
	}
	
	public static List getPrimaryKeyColumns(Connection c, String catalog, String schema, String table) throws SQLException {
		logger.debug("catalog='" + catalog + "'");
		logger.debug("schema='" + schema + "'");
		logger.debug("table='" + table + "'");
		DatabaseMetaData dmd = c.getMetaData();
		ResultSet rs = null;
		try {
			rs = dmd.getPrimaryKeys(catalog, schema, table);
			
			List pkColumns = new LinkedList();;
			while (rs.next()) {
				List tmp = getTableColumns(c, catalog, schema, table, rs.getString(4));
				Column pkColumn = (Column)tmp.get(0);
				pkColumns.add(pkColumn);
			}
			return pkColumns;
		}
		finally {
			if (rs != null) rs.close();
		}
	}
	
	public static List getTableColumns(Connection c, String catalog, String schema, String table) throws SQLException  {
		return getTableColumns(c, catalog, schema, table, null);
	}
	
	public static List getTableColumns(Connection c, String catalog, String schema, String table, String columnPattern) throws SQLException {
		logger.debug("catalog='" + catalog + "'");
		logger.debug("schema='" + schema + "'");
		logger.debug("table='" + table + "'");
		logger.debug("column='" + columnPattern+ "'");
		DatabaseMetaData dmd = c.getMetaData();
		ResultSet rs = null;
		try {
			rs = dmd.getColumns(catalog, schema, table, columnPattern);
			List columns = new LinkedList();
			while (rs.next()) {
				JDBCUtil.Column aCol = new JDBCUtil.Column();
				aCol.sqlTypeName = rs.getString(6);
				aCol.defalutValue = rs.getString(13);
				aCol.name = rs.getString(4);
				aCol.sqlType = rs.getShort(5);
				aCol.sqlColumnLength=rs.getInt(7);
				aCol.sqlDecimalLength=rs.getInt(9);
				aCol.sqlNotNull = ("NO".equals(rs.getString(18)));
				aCol.hibernateType = getHibernateType(
					aCol.sqlType,
					aCol.sqlColumnLength,
					aCol.sqlDecimalLength
				);
				aCol.javaType = getJavaType(
					aCol.sqlType,
					aCol.sqlColumnLength,
					aCol.sqlDecimalLength
				);
				columns.add(aCol);
			}
			return columns;
		}
		finally {
			if (rs != null) rs.close();
		}
		
	}
	
	public static NullableType getHibernateType(int sqlType, int columnSize, int decimalDigits) {
		logger.debug("sqlType=" + sqlType);
		logger.debug("columnSize=" + columnSize);
		logger.debug("decimalDigits=" + decimalDigits);
		NullableType rv=Hibernate.SERIALIZABLE;
		if (sqlType == Types.CHAR || sqlType == Types.VARCHAR) {
			rv = Hibernate.STRING;
		}
		else if (sqlType == Types.FLOAT || sqlType == Types.REAL) {
			rv = Hibernate.FLOAT;
		}
		else if (sqlType == Types.INTEGER) {
			rv = Hibernate.INTEGER;
		}
		else if (sqlType == Types.DOUBLE) {
			rv = Hibernate.DOUBLE;
		}
		else if (sqlType == Types.DATE) {
			rv = Hibernate.DATE;
		}
		else if (sqlType == Types.TIMESTAMP) {
			rv = Hibernate.TIMESTAMP;
		}
		else if (sqlType == Types.TIME) {
			rv = Hibernate.TIME;
		}
		// commented to support JDK version < 1.4
		/*      else if (sqlType == Types.BOOLEAN) {
			rv = Hibernate.BOOLEAN;
		} */
		else if (sqlType == Types.SMALLINT) {
			rv = Hibernate.SHORT;
		}
		else if (sqlType == Types.BIT) {
			rv = Hibernate.BYTE;
		}
		else if (sqlType == Types.BIGINT) {
			rv = Hibernate.LONG;
		}
		else if (sqlType == Types.NUMERIC || sqlType == Types.DECIMAL) {
			if (decimalDigits == 0) {
				if (columnSize == 1) {
					rv = Hibernate.BYTE;
				}
				else if (columnSize < 5) {
					rv = Hibernate.SHORT;
				}
				else if (columnSize < 10) {
					rv = Hibernate.INTEGER;
				}
				else {
					rv = Hibernate.LONG;
				}
			}
			else {
				if (columnSize < 9) {
					rv = Hibernate.FLOAT;
				}
				else {
					rv = Hibernate.DOUBLE;
				}
			}
		}
		return rv;
	}
	
	public static Class getJavaType(int sqlType, int columnSize, int decimalDigits) {
		logger.debug("sqlType=" + sqlType);
		logger.debug("columnSize=" + columnSize);
		logger.debug("decimalDigits=" + decimalDigits);
		Class rv=String.class;
		if (sqlType == Types.CHAR || sqlType == Types.VARCHAR) {
			rv = String.class;
		}
		else if (sqlType == Types.FLOAT || sqlType == Types.REAL) {
			rv = Float.class;
		}
		else if (sqlType == Types.INTEGER) {
			rv = Integer.class;
		}
		else if (sqlType == Types.DOUBLE) {
			rv = Double.class;
		}
		else if (sqlType == Types.DATE) {
			//rv = java.util.Date.class;
			rv = String.class;
		}
		else if (sqlType == Types.TIMESTAMP) {
			//rv = java.util.Date.class;
			rv = String.class;
		}
		else if (sqlType == Types.TIME) {
			//rv = java.util.Date.class;
			rv = String.class;
		}
		// commented to support JDK version < 1.4
		/*      else if (sqlType == Types.BOOLEAN) {
			rv = Boolean.class;
		} */
		else if (sqlType == Types.SMALLINT) {
			rv = Short.class;
		}
		else if (sqlType == Types.BIT) {
//			rv = Byte.class;
			rv = Integer.class;
		}
		else if (sqlType == Types.BIGINT) {
			rv = Long.class;
		}
		else if (sqlType == Types.NUMERIC || sqlType == Types.DECIMAL) {
			if (decimalDigits == 0) {
				if (columnSize == 1) {
//					rv = Byte.class;
					rv=  Integer.class;
				}
				else if (columnSize < 5) {
					rv = Short.class;
				}
				else if (columnSize < 10) {
					rv = Integer.class;
				}
				else {
					rv = Long.class;
				}
			}
			else {
				if (columnSize < 9) {
					rv = Float.class;
				}
				else {
					rv = Double.class;
				}
			}
		}
		return rv;
	}

}






 

 

 

 

  • vobuilder.rar (395.5 KB)
  • 描述: 代码自动生成
  • 下载次数: 303
分享到:
评论

相关推荐

    Webwork+spring+hibernate集成实例

    Webwork、Spring和Hibernate是Java开发中的三大框架,它们各自在不同的层面上为应用程序提供服务。Webwork负责处理用户交互,Spring提供依赖注入和管理事务,而Hibernate则专注于对象关系映射(ORM),使得数据库...

    webwork+spring+hibernate网络购物系统

    1. **源代码**:包括WebWork的Action类、Spring配置文件、Hibernate实体类和映射文件。 2. **JSP页面**:用于展示商品信息、购物车、订单详情等界面。 3. **CSS/JavaScript**:样式文件和脚本文件,负责页面的样式和...

    搭建WEBWORK+SPRING+HIBERNATE框架

    - 配置JDK为MyEclipse的默认Java编译器,确保项目能够正确编译Java源代码。 - 配置JBOSS为MyEclipse的WEB发布容器,便于部署和运行Web应用。 - 在数据库中创建三个表,分别是TEACHER、STUDENT和RELATION,用于...

    webwork+spring+hibernate

    `src`目录则包含了源代码,包括Java实体类、WebWork的Action类、Spring的配置文件等。 综上所述,"webwork+spring+hibernate"整合提供了强大的Web应用开发能力,尤其在处理表单的增删改查方面,通过这三个框架的...

    WebWork+Spring+Hibernate整合开发网络书城+第一讲完整版

    1. 项目源代码:包括Java源文件,如Action类、Service类和DAO类,以及配置文件,如Spring的bean配置文件和Hibernate的实体映射文件。 2. 配置文件:如web.xml,用于部署描述,定义DispatcherServlet和Filter;struts...

    WebWork+Spring+Hibernate整合开发demo

    2. **依赖注入**:Spring会管理Hibernate的数据源、SessionFactory以及其他业务服务,通过依赖注入的方式提供给WebWork使用。 3. **事务管理**:Spring的AOP可以用来管理数据库事务,确保数据的一致性。通常,事务...

    WebWork+Spring+Hibernate源码

    总的来说,这个源码项目为初学者提供了一个学习 WebWork、Spring 和 Hibernate 整合的实例,有助于理解它们各自的作用和相互间的协同工作。通过深入研究,你可以提升自己的 Java Web 开发技能,为今后的项目开发打下...

    WebWork+Spring+Hibernate整合开发网络书城 第4讲

    在"bookstore"目录下,你可能会找到如web.xml(WebWork和Spring的配置)、applicationContext.xml(Spring的配置)、hibernate.cfg.xml(Hibernate的配置)以及相关的Java源代码和资源文件。 总之,通过"WebWork+...

    WebWork+Spring+Hibernate整合开发网络书城

    本项目"WebWork+Spring+Hibernate整合开发网络书城"旨在将这三个框架集成到一个完整的网络应用程序中,构建一个功能完备的在线书店系统。 首先,WebWork是一个轻量级的Java Web应用框架,它提供了强大的动作映射、...

    基于webwork+spring+hibernate的portlet开发实例

    在现代Web应用开发中,基于MVC(Model-View-Controller)架构的框架组合是常见的选择,例如WebWork、Spring和Hibernate。这个“基于webwork+spring+hibernate的portlet开发实例”就是一个典型的应用场景,它展示了...

    WebWork+Spring+Hibernate整合开发网络书城_02(附源代码)

    Web层:WebWork 中间层:Spring IoC 持久层:Hibernate, 需求分析: 用户在注册页面,填写注册信息,确认有效注册成为新用户 用户在登录页面,填写用户名和密码,确认正确后进入系统 用户可以在登录之后,浏览图书分类列表...

    WebWork+Spring+Hibernate整合开发网络书城_01(附源代码)

    Web层:WebWork 中间层:Spring IoC 持久层:Hibernate, 需求分析: 用户在注册页面,填写注册信息,确认有效注册成为新用户 用户在登录页面,填写用户名和密码,确认正确后进入系统 用户可以在登录之后,浏览图书分类列表...

    MyEclipse7.5+flex4+spring3.0.5+struts2.2.1+hibernate3.6.0+blazeds4.0.0.14931完美整合方案

    在IT行业中,构建一个高效的开发环境对于提升项目...内附的jar包和源代码可以帮助开发者快速理解和实践这一整合方案,进一步提升开发技能。然而,实际应用时需要根据项目需求进行调整和优化,确保技术选型的合理性。

    WebWork+Spring+Hibernate整合开发网络书城 第3讲

    文件名为`bookstore`可能代表了整个书城应用的源代码或者项目结构,包括了WebWork的Action类、Spring的配置文件、Hibernate的实体类和映射文件(`.hbm.xml`)、以及可能的JSP视图文件等。通过对这些文件的学习和实践...

    webwork+spring+ibatis很适合初学者的实例

    Spring还包含事务管理、数据访问集成(如JDBC、Hibernate、iBATIS)、服务层支持(如DAO和Service接口)、以及各种工具和模块,如Spring Boot、Spring Cloud等,极大地提高了开发效率和应用的可维护性。 **iBATIS**...

    spring+hibernate+webwork相关配置

    标题 "spring+hibernate+webwork相关配置" 指的是一个集成开发环境的配置,其中涵盖了三个关键的技术框架:Spring、Hibernate和WebWork。这些框架在Java Web开发中非常常见,主要用于实现依赖注入、持久化管理和MVC...

    webwork2.2.7+spring+hibernate+oracle整合

    本项目的重点在于实现WebWork框架(版本2.2.7)、Spring框架、Hibernate持久层框架以及Oracle数据库之间的整合。通过这种整合方式,可以构建出一个功能强大且可维护性高的企业级应用系统。 #### 二、核心配置详解 ...

    HIBERNATE+WEBWORK+SPRING整合 可运行

    - 源代码:Action类(WebWork)、Service类(业务逻辑)、DAO类(数据访问)以及对应的实体类(Hibernate映射)。 - 资源文件:如数据库连接字符串、JDBC驱动、HTML模板等。 通过理解这三个框架的核心功能和整合...

    Hibernate+webwork+spring+oracle框架(2)

    项目中提供的“imti2”文件可能是该项目的源代码或配置文件,包含了上述技术的实现细节。这些文件可能包括Hibernate的映射文件(.hbm.xml)、Spring的配置文件(.xml)、Webwork的动作类(.java)以及数据库连接和...

    Hibernate+webwork+spring+oracle框架(1)

    【标题】"Hibernate+WebWork+Spring+Oracle框架(1)"揭示了这是一个关于整合四大技术的教程或项目实例,主要关注如何在Java Web开发环境中集成这些组件。这个框架组合通常用于构建企业级应用,提供数据持久化、业务...

Global site tag (gtag.js) - Google Analytics