appfuse中生成以S结尾的数据表对应的代码出错的解决方案
2007-12-10 21:05
417 查看
首先使用appfuse是应该尽量避免以S结尾的单词来作为数据表名,但是很多时候并不是这样的。数据表的名字不能改变的时候我们只能从其他方面想办法了!
在google搜索相关的信息,只找到这一篇文章是有用的,并给予我修改的思路。
http://jira.codehaus.org/browse/MIDDLEGEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel
The algorithm for creating singular versions of table names doesn't account for singular words that end in "s". For example, a table called MumbleFooStatus becomes MumbleFooStatu
Suggestion #1: in Util.singularise(), check for a vowel other than "e" before a final "s".
Suggestion #2: change the default behaviour to not singularise tablenames. I think it's bad form for a tool to change the names of my data objects without my consent.
Workarounds: specify table names in build.xml, or if you're using the hibernate plugin, fix the table names in the <dbname>-prefs.properties generated by the plugin and re-run middlegen.
第二点中提到改变middlegen的默认行为让其不去单数化数据表名。
我们要做的有几个步骤(粗略的看了middlegen源码做的修改):
1:下载middlegen源码,下载地址
http://sourceforge.net/project/downloading.php?group_id=36044&use_mirror=jaist&filename=middlegen-2.1-src.zip&92651696
2:解压并编辑MiddlegenTask.java中的代码
把
private static boolean _singularize = true;
改成
private static boolean _singularize = false;
3:重新编译并打包成jar,在middlegen的根目录下输入命令行命令:ant jar即可
4:将新的middlegen-2.1.jar替换目标项目(已生成)中extras/middlegen/lib/middlegen-2.1的middlegen-2.1.jar
这样,在生成以S结尾的数据表名对应的代码就不会出错了!
但是这样做始终有不好的地方:在表示对象复数的地方就会出现不尽人意的代码了,但是不管怎么样,代码还是生成出来了,后期的工作就可以依靠手动去修改。
所以还是尽量去遵循不以S结尾的单词作为数据表名。
在google搜索相关的信息,只找到这一篇文章是有用的,并给予我修改的思路。
http://jira.codehaus.org/browse/MIDDLEGEN-13?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel
The algorithm for creating singular versions of table names doesn't account for singular words that end in "s". For example, a table called MumbleFooStatus becomes MumbleFooStatu
Suggestion #1: in Util.singularise(), check for a vowel other than "e" before a final "s".
Suggestion #2: change the default behaviour to not singularise tablenames. I think it's bad form for a tool to change the names of my data objects without my consent.
Workarounds: specify table names in build.xml, or if you're using the hibernate plugin, fix the table names in the <dbname>-prefs.properties generated by the plugin and re-run middlegen.
第二点中提到改变middlegen的默认行为让其不去单数化数据表名。
我们要做的有几个步骤(粗略的看了middlegen源码做的修改):
1:下载middlegen源码,下载地址
http://sourceforge.net/project/downloading.php?group_id=36044&use_mirror=jaist&filename=middlegen-2.1-src.zip&92651696
2:解压并编辑MiddlegenTask.java中的代码
把
private static boolean _singularize = true;
改成
private static boolean _singularize = false;
3:重新编译并打包成jar,在middlegen的根目录下输入命令行命令:ant jar即可
4:将新的middlegen-2.1.jar替换目标项目(已生成)中extras/middlegen/lib/middlegen-2.1的middlegen-2.1.jar
这样,在生成以S结尾的数据表名对应的代码就不会出错了!
但是这样做始终有不好的地方:在表示对象复数的地方就会出现不尽人意的代码了,但是不管怎么样,代码还是生成出来了,后期的工作就可以依靠手动去修改。
所以还是尽量去遵循不以S结尾的单词作为数据表名。
相关文章推荐
- appfuse中生成以S结尾的数据表对应的代码出错的解决方案
- 由于检索用户的本地应用程序数据路径时出错,导致无法生成 SQL Server 的用户实例。解决方案
- JS随机生成不重复数据的代码分享
- 逆向工程重复生成代码导致出错
- 数据对象类代码的生成小工具
- R语言-将数据按照月份、季度、年份划分及求某个代码(地名、产业名等)对应的累积值
- php生成数据字典,代码
- EF生成代码时报错解决方案:参数错误。 (异常来自 HRESULT:0x80070057 (E_INVALIDARG))
- 配置实现-自创html生成模板搭配xml获取数据无需写代码实现静态网站
- C#------如何生成一个Guid的数据对应SQLServer中的Uniqueidentifier类型
- 根据wsdl文件或者wsdl地址生成对应的java代码
- 由于检索用户的本地应用程序数据路径时出错,导致无法生成 SQL Server 的用户实例
- rand() 不错的生成测试数据的rand代码
- 新浪微博请求数据出错(Android Volley Https证书不信任)的解决方案
- VS2005 保存文件、向导生成代码 速度变慢的解决方案
- WebService客户端生成代码错误解决方案
- Oracle生成查询包含指定字段名对应的所有数据表记录语句
- eclipse编译android开源代码示范,及生成jar引用出错原因解析
- atitit..代码生成流程图 流程图绘制解决方案 java c#.net php v2
- cocos2d-x3.2中2编译生成Android程序出错的解决方案:c++_static报错