Hibernate启动过慢的问题以及我的批处理

Posted on 2005-12-19 08:43 Raistlin 阅读(1394) 评论(0)  编辑 收藏 引用 所属分类: Java

icepeak:
 hibernate肯定没什么问题的
 我也遇到启动很慢的情况,都是我的问题
 你把你的映射文件发给我看看
icepeak:
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
 你用h3,但是却写h2的配置文件,h就傻了 把2变成3就好
icepeak:
 我想你得不到id也许和映射文档有问题也有关系
 什么都不用改,就用identity,再试试看
 我觉得是映射文件配置错误导致了不能读取
 就是2.0和3.0的错误
 
So...问题解决了.

俺用了三个批处理来自动生成hibernate的文件。
 
execant.bat:
d:
cd D:\hibernate-3.0\middlegen-2.1\samples\
rem 打开build.xml修改middlegen配置
editplus.exe build.xml
ant
 
myant.bat:
call execant.bat
pause
rem 复制hbm和java文件到工程目录
xcopy .\build\gen-src\com\glacierbbs\hibernate\*.java E:\eclipse\workspace\JGlacier\src\com\glacierbbs\hibernate\ /Y /D
xcopy .\build\gen-src\com\glacierbbs\hibernate\*.xml E:\eclipse\workspace\JGlacier\src\ /Y /D
rem 替换掉hbm中的字符串
call E:\eclipse\workspace\JGlacier\cutter.bat
pause
 
cutter.bat:
e:
cd E:\eclipse\workspace\JGlacier\src
dir *.xml /d /b /a-d >hbmfiles.txt
rem 将版本2.0改成3.0
for /f %%i in (hbmfiles.txt) do strrpc /s:%%i 2.0 3.0 /c
rem 将hi/lo的max_lo由100改成0...我只需要简单的数字
for /f %%i in (hbmfiles.txt) do strrpc /s:%%i 100 0 /c
del hbmfiles.txt>nul
rem 所有hi/lo算法读的是同一个表中的不同字段
strrpc /s:Board.hbm.xml next_value next_boardid /c
strrpc /s:Post.hbm.xml next_value next_postid /c
strrpc /s:Topic.hbm.xml next_value next_topicid /c
strrpc /s:UserBasic.hbm.xml next_value next_userid /c
strrpc /s:Vote.hbm.xml next_value next_voteid /c
strrpc /s:VoteOption.hbm.xml next_value next_voteoptionid /c
strrpc /s:VoteParticipant.hbm.xml next_value next_voteparticipantid /c
cd ..
pause
 
然后,为每个hibernate生成的java类写个Adapter类...从此世界就安静了....

只有注册用户登录后才能发表评论。

posts - 49, comments - 14, trackbacks - 0, articles - 0

Copyright © Raistlin