WorldStarWB / rapid-framework

Automatically exported from code.google.com/p/rapid-framework
0 stars 0 forks source link

使用最新的rapid-framework3.5.0.1生成一对多关联表的文件时报错 #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
 使用最新的rapid-framework3.5.0.1生成一对多关联表的文件时报错.

1.一对多数据库脚本:
-- 数据字典表
CREATE TABLE `DICT` (   
  `ID` varchar(32) NOT NULL,   
  `NAME` varchar(255) default NULL,
  `CODE` varchar(255) default NULL,   
  `START_LOAD` int(1) default 1, 
  `MEMO` varchar(255) default NULL,   
  `VERSION` int(4) default 0,
  `DELETED` int(1) default 0,
  PRIMARY KEY  (`ID`)   
) ENGINE=InnoDB DEFAULT CHARSET=utf8;  

-- 数据字典明细表
CREATE TABLE `DICT_ITEM` (
  `ID` varchar(32) NOT NULL,
  `DICT_ID` varchar(32) default NULL,
  `KEY` varchar(255) default NULL,
  `VALUE` varchar(255) default NULL,
  `DEFAULTED` int(1) default 0,
  `SHOW_ORDER` int(2) default 1,
  `VERSION` int(4) default 0,
  `DELETED` int(1) default 0,
  PRIMARY KEY  (`ID`),
  KEY `FK_DICT_ITEM_DICT_ID` (`DICT_ID`),
  CONSTRAINT `FK_DICT_ITEM_ID` FOREIGN KEY (`DICT_ID`) REFERENCES `DICT`(`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2. 生成所有表对应的文件时报的错误如下:
Load [generator.properties] from classpath
[Property] outRoot=d:/webapp-generator-output
[Property] basepackage_dir=com/ctf/flexdemo
[Property] jdbc.schema=
[Property] jdbc.password=36273792
[Property] namespace=pages
[Property] hibernate_id_generator=uuid
[Property] basepackage=com.ctf.flexdemo
[Property] version=1.0.0.20100324
[Property]
jdbc.url=jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-
8
[Property] jdbc.catalog=
[Property] jdbc.driver=com.mysql.jdbc.Driver
[Property] jdbc.username=root

[Delete Dir]    d:/webapp-generator-output
***************************************************************
* BEGIN generate Database Table:DICT to ClassName:Dict
***************************************************************
-------------------load template from templateRootDir =
'E:\workspace_utf8\rapid-framework-3.5.0.1\template'
[generate]   template:insert_demo\i18n.properties to insert_demo\i18n.properties
[generate]   template:insert_demo\spring-service.xml to
insert_demo\spring-service.xml
[generate]  
template:java_src\${basepackage_dir}\service\${className}Manager.java to
java_src\com/ctf/flexdemo\service\DictManager.java
[not-generate]   test expression '@compositeId' is
false,template:java_src\${basepackage_dir}\model\${className}Id.java@compositeId
[generate]   template:java_src\${basepackage_dir}\model\${className}.java to
java_src\com/ctf/flexdemo\model\Dict.java
[generate]   template:java_src\${basepackage_dir}\dao\${className}Dao.java
to java_src\com/ctf/flexdemo\dao\DictDao.java
[generate]  
template:java_src\${basepackage_dir}\flex\service\${className}FlexService.java
to java_src\com/ctf/flexdemo\flex\service\DictFlexService.java
[generate]  
template:java_src\${basepackage_dir}\controller\${className}Controller.java
to java_src\com/ctf/flexdemo\controller\DictController.java
[generate]  
template:java_test\${basepackage_dir}\dao\${className}DaoTest.java to
java_test\com/ctf/flexdemo\dao\DictDaoTest.java
[generate]  
template:java_test\${basepackage_dir}\service\${className}ManagerTest.java
to java_test\com/ctf/flexdemo\service\DictManagerTest.java
[generate]   template:java_test\${className}_testdata.xml to
java_test\Dict_testdata.xml
[generate]   template:web\pages\${classNameLowerCase}\show.jsp to
web\pages\dict\show.jsp
[generate]   template:web\pages\${classNameLowerCase}\new.jsp to
web\pages\dict\new.jsp
[generate]   template:web\pages\${classNameLowerCase}\form_include.jsp to
web\pages\dict\form_include.jsp
[generate]   template:web\pages\${classNameLowerCase}\edit.jsp to
web\pages\dict\edit.jsp
[generate]   template:web\pages\${classNameLowerCase}\index.jsp to
web\pages\dict\index.jsp
[skip]       endsWith '.include' template:custom.include
[skip]       endsWith '.include' template:java_copyright.include
[skip]       endsWith '.include' template:java_imports.include
[skip]       endsWith '.include' template:macro.include
[generate]  
template:other\java_hibernate_xml\${basepackage_dir}\model\${className}.java to
other\java_hibernate_xml\com/ctf/flexdemo\model\Dict.java
[generate]  
template:other\java_hibernate_xml\${basepackage_dir}\model\${className}.hbm.xml
to other\java_hibernate_xml\com/ctf/flexdemo\model\Dict.hbm.xml
[not-generate]   test expression '@compositeId' is
false,template:other\java_hibernate_xml\${basepackage_dir}\model\${className}Id.
java@compositeId
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\${className}Delegate.as
to flex_src\com/ctf/flexdemo\dict\DictDelegate.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\${className}Register.as
to flex_src\com/ctf/flexdemo\dict\DictRegister.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\event\List${className}Eve
nt.as
to flex_src\com/ctf/flexdemo\dict\event\ListDictEvent.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\event\Delete${className}E
vent.as
to flex_src\com/ctf/flexdemo\dict\event\DeleteDictEvent.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\event\Get${className}Even
t.as
to flex_src\com/ctf/flexdemo\dict\event\GetDictEvent.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\event\Save${className}Eve
nt.as
to flex_src\com/ctf/flexdemo\dict\event\SaveDictEvent.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\command\Save${className}C
ommand.as
to flex_src\com/ctf/flexdemo\dict\command\SaveDictCommand.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\command\Get${className}Co
mmand.as
to flex_src\com/ctf/flexdemo\dict\command\GetDictCommand.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\command\List${className}C
ommand.as
to flex_src\com/ctf/flexdemo\dict\command\ListDictCommand.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\command\Delete${className
}Command.as
to flex_src\com/ctf/flexdemo\dict\command\DeleteDictCommand.as
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\view\${className}View.mxm
l
to flex_src\com/ctf/flexdemo\dict\view\DictView.mxml
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\view\${className}Detail.m
xml
to flex_src\com/ctf/flexdemo\dict\view\DictDetail.mxml
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\view\${className}Grid.mxm
l
to flex_src\com/ctf/flexdemo\dict\view\DictGrid.mxml
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\view\${className}QueryPan
el.mxml
to flex_src\com/ctf/flexdemo\dict\view\DictQueryPanel.mxml
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\view\${className}DetailWi
ndow.mxml
to flex_src\com/ctf/flexdemo\dict\view\DictDetailWindow.mxml
[generate]  
template:flex_src\${basepackage_dir}\${underscoreName}\${className}ModelLocator.
as
to flex_src\com/ctf/flexdemo\dict\DictModelLocator.as
[generate]   template:flex_src\${basepackage_dir}\vo\${className}.as to
flex_src\com/ctf/flexdemo\vo\Dict.as
[generate]   template:flex_src\${basepackage_dir}\model\${className}.as to
flex_src\com/ctf/flexdemo\model\Dict.as
[generate]   template:flex_src\locale\en_US\${className}.properties to
flex_src\locale\en_US\Dict.properties
[generate]   template:flex_src\locale\zh_CN\${className}.properties to
flex_src\locale\zh_CN\Dict.properties
[generate]   template:flex_src\${className}Index.mxml to flex_src\DictIndex.mxml
[generate]   template:flex_src\readme.txt to flex_src\readme.txt
[skip]       endsWith '.include' template:actionscript_imports.include
[skip]       endsWith '.include' template:actionscript_copyright.include
[skip]       endsWith '.include' template:flex_macro.include
***************************************************************
* BEGIN generate Database Table:DICT_ITEM to ClassName:DictItem
***************************************************************
-------------------load template from templateRootDir =
'E:\workspace_utf8\rapid-framework-3.5.0.1\template'
[insert]     generate content into:insert_demo\i18n.properties
[insert]     generate content into:insert_demo\spring-service.xml
[generate]  
template:java_src\${basepackage_dir}\service\${className}Manager.java to
java_src\com/ctf/flexdemo\service\DictItemManager.java
[not-generate]   test expression '@compositeId' is
false,template:java_src\${basepackage_dir}\model\${className}Id.java@compositeId
[generate]   template:java_src\${basepackage_dir}\model\${className}.java to
java_src\com/ctf/flexdemo\model\DictItem.java
java.lang.RuntimeException: not found table with give name:dict
    at
cn.org.rapid_framework.generator.provider.db.DbTableFactory.getTable(DbTableFact
ory.java:88)
    at
cn.org.rapid_framework.generator.provider.db.model.ForeignKey.getSqlTable(Foreig
nKey.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:840)
    at freemarker.ext.beans.BeanModel.invokeThroughDescriptor(BeanModel.java:276)
    at freemarker.ext.beans.BeanModel.get(BeanModel.java:183)
    at freemarker.core.Dot._getAsTemplateModel(Dot.java:76)
    at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
    at freemarker.core.Assignment.accept(Assignment.java:90)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
    at freemarker.core.Environment.visit(Environment.java:417)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.Macro$Context.runMacro(Macro.java:172)
    at freemarker.core.Environment.visit(Environment.java:603)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.Environment.process(Environment.java:190)
    at freemarker.template.Template.process(Template.java:237)
    at
cn.org.rapid_framework.generator.Generator.saveNewOutputFileContent(Generator.ja
va:224)
    at
cn.org.rapid_framework.generator.Generator.generateNewFileOrInsertIntoFile(Gener
ator.java:157)
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:116)
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:77)
    at
cn.org.rapid_framework.generator.GeneratorFacade.generateByTable(GeneratorFacade
.java:44)
    at
cn.org.rapid_framework.generator.GeneratorFacade.generateByAllTable(GeneratorFac
ade.java:37)
    at cn.org.rapid_framework.generator.GeneratorMain.main(GeneratorMain.java:21)
2010-03-24 08:15:45,796 ERROR [freemarker.runtime] - <Error on line 187,
column 9 in java_src\${basepackage_dir}\model\${className}.java
foreignKey.sqlTable is undefined.
It cannot be assigned to fkSqlTable>

Error on line 187, column 9 in
java_src\${basepackage_dir}\model\${className}.java
foreignKey.sqlTable is undefined.
It cannot be assigned to fkSqlTable
The problematic instruction:
----------
==> assignment: fkSqlTable=foreignKey.sqlTable [on line 187, column 9 in
java_src\${basepackage_dir}\model\${className}.java]
 in user-directive generateJavaManyToOne [on line 39, column 9 in
java_src\${basepackage_dir}\model\${className}.java]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Error on line 187, column 9 in
java_src\${basepackage_dir}\model\${className}.java
foreignKey.sqlTable is undefined.
It cannot be assigned to fkSqlTable
    at freemarker.core.Assignment.accept(Assignment.java:111)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
    at freemarker.core.Environment.visit(Environment.java:417)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.Macro$Context.runMacro(Macro.java:172)
    at freemarker.core.Environment.visit(Environment.java:603)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.Environment.process(Environment.java:190)
    at freemarker.template.Template.process(Template.java:237)
    at
cn.org.rapid_framework.generator.Generator.saveNewOutputFileContent(Generator.ja
va:224)
    at
cn.org.rapid_framework.generator.Generator.generateNewFileOrInsertIntoFile(Gener
ator.java:157)
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:116)
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:77)
    at
cn.org.rapid_framework.generator.GeneratorFacade.generateByTable(GeneratorFacade
.java:44)
    at
cn.org.rapid_framework.generator.GeneratorFacade.generateByAllTable(GeneratorFac
ade.java:37)
    at cn.org.rapid_framework.generator.GeneratorMain.main(GeneratorMain.java:21)
Exception in thread "main" java.lang.RuntimeException: generate 'Database
Table:DICT_ITEM to ClassName:DictItem' oucur error,template
is:java_src\${basepackage_dir}\model\${className}.java
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:118)
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:77)
    at
cn.org.rapid_framework.generator.GeneratorFacade.generateByTable(GeneratorFacade
.java:44)
    at
cn.org.rapid_framework.generator.GeneratorFacade.generateByAllTable(GeneratorFac
ade.java:37)
    at cn.org.rapid_framework.generator.GeneratorMain.main(GeneratorMain.java:21)
Caused by: freemarker.core.InvalidReferenceException: Error on line 187,
column 9 in java_src\${basepackage_dir}\model\${className}.java
foreignKey.sqlTable is undefined.
It cannot be assigned to fkSqlTable
    at freemarker.core.Assignment.accept(Assignment.java:111)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
    at freemarker.core.Environment.visit(Environment.java:417)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.Macro$Context.runMacro(Macro.java:172)
    at freemarker.core.Environment.visit(Environment.java:603)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:210)
    at freemarker.core.Environment.process(Environment.java:190)
    at freemarker.template.Template.process(Template.java:237)
    at
cn.org.rapid_framework.generator.Generator.saveNewOutputFileContent(Generator.ja
va:224)
    at
cn.org.rapid_framework.generator.Generator.generateNewFileOrInsertIntoFile(Gener
ator.java:157)
    at
cn.org.rapid_framework.generator.Generator.generateByModelProvider(Generator.jav
a:116)
    ... 4 more

Original issue reported on code.google.com by ctfzh....@gmail.com on 24 Mar 2010 at 9:09

Attachments:

GoogleCodeExporter commented 8 years ago
照错误来看,是由于大小写敏感的问题导致 
DbTableFactory.getTable()方法在数据库中没有找
到表.

我现在的解决办法是将DbTableFactory.getTable()方法会使用重试,�
��略大小写进行查找.

        Table t = _getTable(sqlTableName);
        if(t == null ) {
            t = _getTable(sqlTableName.toUpperCase());
        }
        if(t == null ) {
            t = _getTable(sqlTableName.toLowerCase());
        }

具体新的源码下载:
http://rapid-framework.googlecode.com/svn/trunk/rapid-
framework/generator/src/cn/org/rapid_framework/generator/provider/db/DbTableFact
ory.j
ava

Original comment by bad...@gmail.com on 24 Mar 2010 at 11:27

GoogleCodeExporter commented 8 years ago
确认没有问题的话,修改状态为Fixed

Original comment by bad...@gmail.com on 25 Mar 2010 at 12:53

GoogleCodeExporter commented 8 years ago
经过下载最新的DbTableFactory.getTable()方法,一对多的问题已经解
决.谢谢badqiu.

但生成的只生成了多对一的关联,没有生成一对多的关联. 

而且多对多表的那个中间表没有必要生成一个联合主键类吧? 

Original comment by ctfzh....@gmail.com on 26 Mar 2010 at 2:18