随笔 - 23  文章 - 3  trackbacks - 0
<2006年4月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用链接

留言簿(1)

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

注意writer的参数有多个,特别是有一个boolean的参数决定刷新或在附加文本

            log  =    new  PrintWriter( new  FileOutputStream(fl, true ), true );
            SimpleDateFormat df 
=   new  SimpleDateFormat( " yyyy.MM.dd 'at' hh:mm:ss\n "
);
            Date now 
=   new
 Date();
            String dateformat 
=
 df.format(now)
            BufferedWriter bf  
=   new  BufferedWriter( new  FileWriter(fl,  true
));
            bf.append(dateformat);
            bf.close();
            log.println(
" start connection databse: "
);
            log.println(
" driver name: " .concat(driveName);


输出的结果示例:
2006.12.12 at 10:21:13
start connection databse:
driver name:oracle.jdbc.driver.OracleDriver

posted @ 2006-12-12 12:16 aimy 阅读(214) | 评论 (0)编辑 收藏
1、org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xindeco.business.pojo.NonageRegister#82]
 at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
 at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:65)
 at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
 at org.apache.catalina.core.ApplicationDispatcher.forward

错误的原因:
在nonregsiter中已经手动删除了id=‘82’的记录,而在WF_task以及wf-proces中还有bizclass = '3' && bizId = '82'的记录,只要删除wf-task中相应的记录.
posted @ 2006-07-09 16:17 aimy 阅读(227) | 评论 (0)编辑 收藏

ProcessInstance.hbm.xml:

<? xml version = " 1.0 "  encoding = " UTF-8 " ?>

<! DOCTYPE hibernate - mapping PUBLIC
    
" -//Hibernate/Hibernate Mapping DTD 3.0//EN "  
    
" http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >

< hibernate - mapping
>
    
< class
        name
= " com.xindeco.workflow.ProcessInstance "
        table
= " WF_PROCESS "
        dynamic
- update = " true "
        dynamic
- insert = " true "
        select
- before - update = " false "
        optimistic
- lock = " version "
    
>

        
< id
            name
= " ID "
            column
= " ID "
            type
= " long "
            length
= " 30 "
        
>
            
< generator  class = " native " >
            
</ generator >
        
</ id >

        
< discriminator
            column
= " bizClass "
            type
= " string "
        
/>
        
        
< property
            name
= " state "
            type
= " java.lang.Integer "
            update
= " true "
            insert
= " true "
            access
= " property "
            column
= " state "
            length
= " 10 "
        
/>
        
        
< many - to - one
            name
= " flow "
            
class = " com.xindeco.workflow.WFFlow "
            cascade
= " none "
            outer
- join = " auto "
            update
= " true "
            insert
= " true "
            access
= " property "
            column
= " flowId "
        
/>

        
< set
            name
= " tasks "
            lazy
= " true "
            inverse
= " true "
            cascade
= " delete "
            sort
= " unsorted "
        
>

              
< key
                  column
= " processId "
              
>
              
</ key >

              
< one - to - many
                  
class = " com.xindeco.workflow.WFTask "
              
/>

        
</ set >

    
</ class >

</ hibernate - mapping >

CollRegPI.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
      
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-access="field" >

  
<subclass name="com.xindeco.business.pojo.wf.CollRegPI"
            discriminator
-value="2"
            
extends="com.xindeco.workflow.ProcessInstance"
            lazy
="false">

            
<many-to-one name="collReg"
                 
class="com.xindeco.business.pojo.CollReg"
                 column
="bizId"
                 cascade
="none"/>
</subclass>
</hibernate-mapping>

数据库的数据:
     id    flowid    bizId   bizClass   state
  21       2           9          2              0
 22         2         10         2              0
 23         2         11         2              0
 24         2         12         2              0
 25         2         13         2              0
 26         2         14         2              0
 29         2         17         2              0
 30         2         18         2              1
 44         4         1          32             0
 45         4         2           32             1
 46         5          1          33             0
 47         5          2           33             1
 48         5          3           33             0
 50         3          1            3              0
 51         3         1            3              0

如果bizclass=2是同一种类型的class。由        
         <discriminator
            column
="bizClass"
            type
="string"
        
/>来表示。
posted @ 2006-07-06 10:37 aimy 阅读(384) | 评论 (0)编辑 收藏
org.hibernate.hql.QuerySplitter - no persistent classes found for query class:
意味着你没有将someclass的配置文件放在hibernate.config或没有写配置文件。
posted @ 2006-07-04 10:30 aimy 阅读(1169) | 评论 (0)编辑 收藏
1,通过构造函数创建bean
 <bean id="baseDAO" class="com.aimy.core.dao.impl.BaseDAOImpl">
相当于
basedaoimpl baseDAO 
= new BaseDAOImpl();
2,通过静态工厂创建bean
<bean id="driver1" class="com.aimy.driver.driverManager"
factory
-method="createInstance"/>
相当于
Object driver1 
= driverManager.createInstance();

其中没有指定driverManager.createInstance();返回对象的类型,而且createInstance()必须是static方法
3,通过实例工厂方法创建bean
<bean id="father" class="com.aimy.Father"/>
........
<bean id="son" factory-bean="father" factory-method="createSon"/>
相当于
Father father 
= new Father();
Object son 
= father.createSon();

其中father和son必须在同一个bean工厂或父bean工厂,即在同一个applicationcontext或子applicationcontext


二、如果applicationcontext默认预实例化那些singleton bean,这样就可以在beanfactory装载时就检查出错误,而如果singleton bean设置为lazy-mode,
posted @ 2006-06-26 23:26 aimy 阅读(233) | 评论 (0)编辑 收藏
hibernate 保存空值的细节
1。如果字段在pojo类中是复杂对象类型,则在数据库用nulll表示。
2。如果字段在pojo类中是简单数据类型,则在数据库用0表示。
posted @ 2006-06-26 09:56 aimy 阅读(170) | 评论 (0)编辑 收藏
1. document.name.value----->document.all.name.value
2. eval(document.all.name)---->eval('document.all.name')
3.javascript:window.history.go(-1)
4、在action方法中只要抛出exception,就会跳到jspexception页面中,怎么处理。
posted @ 2006-06-22 13:19 aimy 阅读(188) | 评论 (0)编辑 收藏
为了将业务逻辑放到service层,比如判断登陆用户的信息,而在service层无法用SysUser user = (SysUser) request.getSession().getAttribute(WebConstants.SESSION_USER);因此在BaseService设一个属性为
      public void setOperator(Entity operator);
      public Entity getOperator();
posted @ 2006-05-17 11:17 aimy 阅读(291) | 评论 (0)编辑 收藏
   private static WFEngine instance;
    public static final WFEngine getInstance() {
        return instance;
    }
posted @ 2006-05-17 10:05 aimy 阅读(195) | 评论 (0)编辑 收藏

<sqlMap namespace="PersonnelRegist">

  <typeAlias alias="ID" type="com.xindeco.core.pojo.IDEntity"/>
  </select>
   <select id="GraAppInfo.searchUpApply" parameterClass="com.xindeco.business.dto.GraAppInfoDTO"    resultClass="ID" cacheModel="userCache">
   select distinct a.ID AS id
   from TGraAppInfo a  left join TEMPLOYUNITBASEINFO b on a.unit=b.MEMBERID
   where appstatus = '1'
   <dynamic>
   <isNotEmpty prepend="AND" property="name">(a.name like '%' + #name# + '%')</isNotEmpty>
   <isNotEmpty prepend="AND" property="unit">(b.UNITNAME like '%' + #unit# + '%')</isNotEmpty>
   </dynamic>
  </select>
</sqlMap>

注意sqlmapGraAppInfoDTO的name,unit只能是基本数据类型,不能是复杂数据类型.
2、<script>的位置
<script>
form1.srchEdit.value='<%=srchEdit%>';
form1.srchType.value='<%=srchType%>';    
</script>
<form>
<input type="text" name="srchEdit"/>
<input type="text" name="srchType"/></form>
与<form>
<input type="text" name="srchEdit"/>
<input type="text" name="srchType"/>
</form>
<script>
form1.srchEdit.value='<%=srchEdit%>';
form1.srchType.value='<%=srchType%>';    
</script>
的差别,必须在form加载完对它赋值,否则srchEdit又重新加载,为null

3、hibernate属性设置出现错误:
      如果pojo类取fSUnit属性名,系统将无法识别。get和set将取不到值。

posted @ 2006-05-11 10:06 aimy 阅读(308) | 评论 (0)编辑 收藏
5-8
昨天晚上我给他讲了英文笑话,虽然他指出了很多错误,但那是个好的开始。
     A redneck bought a tickect and won the lottery.
     He went to claim it .He said:"I want $20 million right now"
who verified his tickect number replied to him :"No,sir.It doesn't work this way.we give you $1 million today,you will get the rest spread on for the next 19 years."
     The redneck said:"I want all my money.I won it,and i want it"
      The man had to explained to him patiently:"you would get $1 million,and the rest during the next 19 years."
      The redneck ,furious with the man ,screamed out:"I want all my money.If you don't give  me all my money ,i want my dollar back!"
注意读音:money、million、battle zone。

我的叔叔silas   H.E.Bates
      我的叔叔silas  活了九十五岁,有充足的时间去尝试很多事情.他一度做过掘墓人.
      In a life of 95 years ,my uncle found time to try most things, there was a time he become a gravedigger.
posted @ 2006-05-09 14:34 aimy 阅读(109) | 评论 (0)编辑 收藏

1、get是从服务器上取得数据,post是向服务器上传送数据。
2、get是将参数数据队列(表单)加到提交表单的action所指定的url中,值和表单的各个字段是相互对应的,Get将表单中数据的按照variable=value的形式,添加到action所指向的URL后面,并且两者使用“?”连接,而各个变量之间使用“&”连接,在url中是可以看见的,
post是将表单各个字段放在http header内一起传送到action中的URL中,
3、get,服务器通过request.getQuery()获得对应的值;对于post,服务器通过request.getForm()表单的值。
4、get,传送的数据小,post,传送的数据大,上传文件一般用post
特别注意:
<form action="/GraAppInfo/GraAppInfo.do?method=UpList"  method="post">
<select name="srchType">
     <option value="0">名字</option>
     <option value="1">用人单位</option>
   </select>
   <input height="18" name="srchEdit" type="text" align="right">
  <input  type="submit" value="查询">

显示的URL:http://localhost:8080/GraAppInfo/GraAppInfo.do?method=UpList
<form action="/GraAppInfo/GraAppInfo.do?method=UpList"  method="get">
显示的URL:http://localhost:8080/GraAppInfo/GraAppInfo.do?srchType=0&srchEdit=da
可见post 会覆盖action中的参数,
5、中文用post传递不会出现乱码,用get传递会出现乱码
所以传到action后要通过
String srchEdit = new String(graForm.getSrchEdit().getBytes("iso8859-1"), "gb2312");
处理。
二、传到页面的值乱码

posted @ 2006-05-08 09:50 aimy 阅读(215) | 评论 (0)编辑 收藏
<props>
        <prop key="add*">PROPAGATION_REQUIRED</prop>
        <prop key="cancel*">PROPAGATION_REQUIRED</prop>
        <prop key="create*">PROPAGATION_REQUIRED</prop>
        <prop key="save*">PROPAGATION_REQUIRED</prop>
</props>
如果service层没有用这些字母开头命名,spring自动将它处理为默认的访问模式--PROPAGATION_REQUIRED,readOnly
如果在action直接调用dao层也不行,比如service.getbaseDAO.update(object)也会出现类似的错误,因为事务被拦截了,所以dao层的方法最好用protect,这样只有同一个包里的类可以调用它的方法。
posted @ 2006-04-30 14:37 aimy 阅读(84) | 评论 (0)编辑 收藏

MENUID UPMENUID MENUNAME MENUURL MENUSEQ LAYERLEVEL RIGHTCODE ISSHOW TABLETYPE STARTSTATE
 
 1083 1001 毕业生招聘 # 1 1 1083 1  
 1084 1083 毕业生申报 /GraAppInfo/GraAppInfo.do?method=graappinfolist 6 9 1084 1  

menuid 该层菜单的id  upmenuid 上一层菜单id  menuname 菜单名字
menuurl 该层菜单的地址(首层菜单为#,没有地址)
menuseq 该层菜单在上一层菜单的顺序
layerlevel 如果是最后一层的菜单为9,其他为1
rigntcode关联到权限表=menuid
idshow 是否显示

权限表:
RIGHTID RIGHTCODE ROLETYPE ROLEID DEPTID USERID MENUID FUNNAME
1084                1084              2                    2                  
                     0        0            1084           毕业生申报
rightid=menuid=rightcode,roletype,roleid

这是单位的菜单设置和权限设置(1000〈menuid〈2000)

2、人事单位内部的设置(4000〈munuid〈5000)
权限的设置通过页面来控制

posted @ 2006-04-30 11:19 aimy 阅读(144) | 评论 (0)编辑 收藏
为了在每个dao和service 类都能用到log,在basedaoimpl和baseserviceimpl都实现方法:
    public Log getLogger() {
        if (log == null) {
            log = LogFactory.getLog(this.getClass());
        }
        return log;
    }

在类中就可以调用log
this.getLogger

2、<input type="text" name="password">
与form的属性对应,password是大小分别。
posted @ 2006-04-25 18:07 aimy 阅读(126) | 评论 (0)编辑 收藏

public class EmployUnitBaseInfo
{   
 
    private long ID; //用人单位系统编号---逻辑主键
    private String unitCode; //用人单位代号--业务主键
}
1、    使用逻辑主键,分页比较方便
2、    有可能unitcode会改变,用id可以保证当unitcode改变时,这个实体还存在

{C5A4CCF8-A282-4700-A5F3-FA6A5246D9F2}0.jpg

在页面上必须返回workpost + demandid,,
pojo 中的demand类如下:只有以下属性的setter和getter
    private String usedNeedNum;
    private int unitId;
    private String demandInfo;
 private long ID;
    private String needNum;
    private String position;
必须再添加一个属性demandInfo,
而在另一个毕业生申报中又要如图上操作,,如何在service层向页面层传递这些信息(测试程序员(剩2需求数))
 public class DemandServiceImpl
    extends BaseServiceImpl implements DemandService{
    public List getDemandList(int unitId)
    {
          long demandId;
          int needNum;
          int usedNeedNum;
          int lastNum;
         
          String demandInfo;
          TRealDemandDAOImpl dao = (TRealDemandDAOImpl) this.getBaseDAO();
          List list = dao.getSpareDemandByUnitId(unitId);
          Iterator it = list.iterator();
          while(it.hasNext())
          {
              TRealDemand demand = (TRealDemand) it.next();
              demandId = demand.getID();
              needNum =  Integer.parseInt(demand.getNeedNum()); 
              usedNeedNum = Integer.parseInt(demand.getUsedNeedNum());
              if(needNum>usedNeedNum)
              {
                  lastNum = usedNeedNum-needNum;
                  demandInfo = demand.getPosition()+" 剩 " + lastNum +" 需求数 ";
              }
             
          }
          return list;
    }
}

在action层再通过以下代码向页面传递数据:

DemandService demandService = (DemandService) this.getBean("DemandService");
 request.setAttribute("demandList",demandService.findDemandListByUnitId(unitInfo.getID()));



4、注意DemandServiceImpl 是实现类,DemandService 是interface
DemandService demandService = (DemandService) this.getBean("DemandService");
和DemandServiceImpl demandService = (DemandServiceImpl) this.getBean("DemandService");

虽然两个的操作一样,但是demandService是接口但可以执行相应的操作,起到黑箱子的作用。

5、记得在action中添加一个实体时,要通过idcard取得sex和birthday的属性加到内存中(表相对应的pojo)

posted @ 2006-04-21 10:36 aimy 阅读(99) | 评论 (0)编辑 收藏
 String mSqlStr = " SELECT ";
  mSqlStr += " UnitName, ";
  mSqlStr += " FSUName, FSUPostNumber, FSUAddress ";
  mSqlStr += " FROM xmpi.v_UnitInfoAll ";
   mSqlStr += " WHERE UnitCode = '" + s_sUserName + "'"; 
  
    如果s_sUserName="hello",则" WHERE UnitCode = '" + s_sUserName + "'"就相当于" WHERE UnitCode = '" + "hello" + "'" ,  最后等于" WHERE UnitCode = ' hello';

1、value="<logic:notEmpty name="IDCardNo"><bean:write name="IDCardNo"/></logic:notEmpty>"
      如果直接用value="<%=IDCardNo%>",当IDCardNo为null时,页面会出错。而logic:notEmpty表示不为空时,才执行note中间的代码。
2、<logic:iterate id="nation" name="nationList" >
     <option value="<bean:write name="nation" property="codeID"/>"><bean:write name="nation" property="codeName"/></option>
    </logic:iterate>
表示一组循环,每次循环都从list nationlist(name="nationList")中取出一个个体nation(id="nation")
注意:当IDCardNo为string,只要指明name属性(name="IDCardNo"),当nation为对象,不仅要指明object名(name="nation" ),还要指明这个对象内的属性(property="codeID")

3、在serviceimpl层通过 PersonnelDAO dao = (PersonnelDAO)this.getBaseDAO()取得dao类操作,在action层PersonnelService service = (PersonnelService)this.getBean("personnelService")取得serviceimpl类,,同样在application中设置为什么方法不一样??

4、单个条件查询
      string id;
      string hql = new String(" from  PersonnelBaseInfo  where idCardNO=?");
      Object[] object = new Object[] {id}
       this.getHIbernateTemplate().find(hql,object);

     多个条件查询
      string id,name;
      string hql = new String(" from  PersonnelBaseInfo  where id=?&&name=?");
      Object[] object = new Object[] {id,name}
     //object[0]=id;
     //object[1]=name
      this.getHIbernateTemplate().find(hql,object);

5、记得研究jslib.jsp中的getBaseCode??

6、不用身份证做TGraAppInfo主键的原因是有可能两家公司同时抱同一个人,,但审核只能通过一份。

7,pojo与actionform的不同:pojo中对应于数据库外键的属性,实体来表示;比如表user内有一个字段为studentid,则pojo--userinfo中有一个属性为student。
而对应于web页面有一个类为userform,有一个属性为long。

8。dto与pojo类的不同
      dto是中间传递类,是用来封装参数的类,比如将查询条件太多,则封装成一个dto


9。import com.xindeco.business.IEmployUnitData;==相当于现在系统的service
import com.xindeco.business.employunitdata.EmployUnitAPI;相当于现在系统的serviceimpl
import com.xindeco.business.employunitdata.EmployUnitBaseInfoVO;//相当于现在系统的pojo

10 codeApi类
        codeApi.findCodeInfoByCodeID(sexID).getCodeName()
     根据codeid查找一行记录;
         codeApi.findCodeList(BaseCodeConstants.CODETYPE_NATION)
     根据codetypeid查找一串记录;
         tcode的表结构为
       CODEID        CODETYPEID      CODEVALU        CODENAME        ACTIVE 
比如:      1                        1                        1                             男                    1
CODECOMPAREVALUE          UPCODEID   
                  1                                      0
         tcodetype的表结构为:

   CODETYPEID      CODETYPENAME
               1                        性别 
    
    学制:  CODETYPE_EDUSYSTME    培养方式:CODETYPE_UNITGRADE     五大生: CODETYPE_RECRUITTARGET
posted @ 2006-04-19 16:56 aimy 阅读(166) | 评论 (0)编辑 收藏
<hibernate-mapping>
<class
name="org.hibernate.sample.TUser"
table="t_user"
dynamic-update="true"
dynamic-insert="true"
>
……
<set
name="addresses"
table="t_address"
lazy="false"   \\延迟加载,当映射到对应的pojo时,没有加载到addresses对应的属性,通过Taddress.getAddress()取不到值,而且特别注意当session一关闭时,就取不到了
inverse="false" \\反转控制,当inverse="true"时,时通过被控方address.setUer()来维系他们之间的关系.
cascade="all" 
sort="unsorted"   \\是否排序
order-by="zipcode asc"  \\以什么方式排序
>
<key
column="user_id"
>
</key>  \\外键
<one-to-many
class="org.hibernate.sample.TAddress"
/>
</set>
……
</class>
posted @ 2006-04-19 10:37 aimy 阅读(228) | 评论 (0)编辑 收藏
1.注意安装程序的时候要改变log文件的目录,在log4j.properties中log4j.appender.R.File=E:\\NewFroject\\JmrlProject\\06.NewSourceCode\\newJmrl\\webapp\\WEB-INF\\classes\\jmrl.log
2、开始一个新的项目,必须重新设置tomcat,否则tomcat可能老是启动原来的项目
3、开始一个新的webapp要把webapp-->properties--->build-->build app archive 设为never ,还有build app directory为never这样可以加快编译的过程.
      
posted @ 2006-04-17 17:05 aimy 阅读(96) | 评论 (0)编辑 收藏

1、
org.springframework.orm.ObjectRetrievalFailureException: Object of class [com.xindeco.myregister.pojo.MyRegisterInfo] with identifier [14]: not found
MyRegisterInfo在数据库没有identifier [14]对象。


2、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.xindeco.myregister.pojo.MyRegisterInfo column: password (should be mapped with insert="false" update="false")

出错原因:password 和repassword同时对应数据库表中的password一列,同时update和insert都设为true。
xml文件如下:
    <property name="password"
                          type="java.lang.String"
                          update="true"
                          insert="true"
                          access="property"
                          column="password"
                          length = "32"
                          />

                         <property name="repassword"
                          type="java.lang.String"
                          update="false"
                          insert="false"
                          access="property"
                          column="password"
                          length = "32"
                          />
解决的方法:
将repassword的insert和update设为false。


3、
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed;
nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for ID in class

错误原因:hibernate的映射文件中ID是大写的,而pojo的类中id是小写的

注意事项:每个pojo的类都要继承abstractEntity,其中abstractEntity类有个ID的属性要重写
 public abstract class AbstractEntity
    implements Entity, BaseDTO {

    abstract public long getID();

    abstract public void setID(long id);

    public int hashCode() {
        return (int)this.getID();
    }

    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof Entity) {
            return this.getID() == ( (Entity) obj).getID();
        }
        return false;
    }
}

4、
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition

错误原因:
在application.xml文件中deleteRegister方法以delete开头,并没有被设定为可更改的,应如下设置:
 <!--为事物创建代理类,并指定方法的事物类型-->
  <bean id="baseTxProxy" lazy-init="true" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
      <ref bean="transactionManager"/>
    </property>
    <property name="transactionAttributes">
      <props>
        <prop key="add*">PROPAGATION_REQUIRED</prop>
        <prop key="cancel*">PROPAGATION_REQUIRED</prop>
           </props>
    </property>
  </bean>
加上一行
  <prop key="delete*">PROPAGATION_REQUIRED</prop>

5、
   ERROR org.apache.struts.util.RequestUtils - Error creating form bean of class com.xindeco.business.web.form.GraAppInfoForm

public class  GraAppInfoForm
extends ActionForm 错误写成
public abstratic class  GraAppInfoForm
extends ActionForm

6、
2006-04-25 08:56:38,495 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@8e2fb5
java.lang.ClassCastException: $Proxy0
 at com.xindeco.business.web.action.GraAppAction.newone(GraAppAction.java:30)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
 at com.xindeco.core.web.action.BaseAction.dispatchMethod(BaseAction.java:153)
 at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)


actioin类中的newone方法如下:
public  class GraAppAction
    extends BaseAction {
    public ActionForward newone(ActionMapping mapping, ActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response) throws Exception {
       GraAppService  graservice = (GraAppService) this.getBean("GraAppService");
}

applicationcontext中的GraAppService的配置如下:
    <bean id="GraAppDAO" class="com.xindeco.business.dao.impl.GraAppDAOImpl">
    <property name="support">
      <ref local="support"/>
    </property>
    <property name="sessionFactory">
      <ref local="sessionFactory"/>
    </property>
  </bean>
  <bean id="GraAppService" parent="baseTxProxy">
    <property name="target">
      <bean class="com.xindeco.business.service.impl.GraAppServiceImpl" autowire="byName">
        <property name="baseDAO">
          <ref bean="GraAppDAO"/>
        </property>
      </bean>
    </property>
  </bean>

因此this.getBean("GraAppService");是为了得到GraAppServicImpl类的实现。GraAppService是interface
public class GraAppServiceImpl extends BaseServiceImpl
    implements GraAppService{
}

7、org.hibernate.hql.ast.QuerySyntaxException: Demand is not mapped. [from Demand where unitid = ? and needNum > usedNeedNum]

hibernate.cfg.xml没有配置Demand.hbm.xml文件的目录

8、org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: 列名 'id' 无效。
java.sql.SQLException: 列名 'name' 无效。

因为hibernate声明的id,name的columnid属性没有与数据库的字段对应,所以id,name无效。


9、java.lang.NumberFormatException: null
 at java.lang.Integer.parseInt(Integer.java:415)
 at java.lang.Integer.parseInt(Integer.java:497)
 at com.xindeco.business.service.impl.DemandServiceImpl.findDemandListByUnitId(DemandServiceImpl.java:33)

错误语句为
 needNum = Integer.parseInt(demand.getNeedNum());
 usedNeedNum = Integer.parseInt(demand.getUsedNeedNum());
因为demand.getUsedNeedNum()==null,无法转化为string 类型,

10、rg.apache.jasper.JasperException: /GraAppInfo/GraAppInfoNew.jsp(343,29) According to TLD, tag bean:write must be empty, but is not

错误的原因:
              <select name="politicsID" >
             <option value="">请选择</option>
       <logic:notEmpty name="politicsList">
                <logic:iterate id="politics" name="politicsList">
                          </logic:notEmpty>
           <option value="<bean:write name="politics" property="codeID"/>"><bean:write name="politics" property="codeName"/></option>
          </logic:iterate>
 </select>
就因为少了/>
以后懂得通过查找字数,来检查错误


11、2006-04-26 13:27:54,812 ERROR com.xindeco.core.util.BeanUtils - bean property [Nation] copy failed
com.xindeco.core.exception.ConvertException: org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: java.lang.String; nested exception is org.hibernate.MappingException: Unknown entity: java.lang.String

beanUtil.beanCopy(grapojo,form,BizConstants.CONVERTER);
要求:
1、pojo类的属性只有与form属性名字相同,才能beancopy成功
2、pojo中属性是实体,在form中一定要用int,long表示
出现这错误的原因是pojo中的属性不是实体,而错误写成:
string
 private String nation;应改成 private Syscode nation;

12、
2006-04-26 14:38:37,843 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@fa1b2d
java.lang.NullPointerException
 at com.xindeco.business.web.action.GraAppAction.newone(GraAppAction.java:43)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

hibernate配置文件没改,程序找不到相应的类
        <many-to-one
            name="FSUnit"
            class="com.xindeco.business.pojo.EmployUnitBaseInfo"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="fSUnit"
        />

其实FSUnit对应的类应该是FSUnit
        <many-to-one
            name="FSUnit"
            class="com.xindeco.business.pojo.FSUnit"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="fSUnit"
        />

13、
org.hibernate.MappingException: An association from the table GraAppInfo refers to an unmapped class: com.xindeco.business.pojo.FSUnit

错误原因:hibernate.cfg.xml没有配置fsunit.hbm.xml文件的位置

14、
java.lang.ClassCastException: com.xindeco.business.dao.impl.GraAppDAOImpl
at com.xindeco.business.service.impl.GraAppServiceImpl.addGraduateApp(GraAppServiceImpl.java:16)
GraAppServiceImpl.java:16
第16行: GraAppDAO dao = (GraAppDAO) this.getBaseDAO();//其实得到的是GraAppDAOImpl

错误的原因是
public class GraAppDAOImpl
    extends BaseDAOImpl {

}
没有实现GraAppDAO接口,正确的做法是
public class GraAppDAOImpl
    extends BaseDAOImpl implements GraAppDAO {
}
先继承后实现


15、2006-04-27 08:38:54,078 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@1d6399b
java.lang.ClassCastException: com.xindeco.business.pojo.SysCode
 at org.hibernate.type.StringType.set(StringType.java:26)
 at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:63)
 at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:40)

一般是因为hibernate声明类型和pojo类声明的类型不一样,并且前面已经出现了Hibernate: insert into TGraAppInfo (name, whereFrom, degree, college, speciality, studentRelTel, remark, higherEduLength, highSchool, studyResume, normalOrNot, proxyUnit, workPost, workPlace, studentAddress, studentPostNumber, nation, appStatus) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
的操作提示,查出错误的原因有:
        <many-to-one
            name="demand"
            class="com.xindeco.business.pojo.Syscode"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="demandID"
        />
         <property
            name="appStatus"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="appStatus"
            length="10"
        />
应改为    
        <many-to-one
            name="demand"
            class="com.xindeco.business.pojo.Demand"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="demandID"
        />

  <many-to-one
            name="nation"
            class="com.xindeco.business.pojo.SysCode"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="nation"
        />

16、
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.xindeco.business.pojo.SysCode
 at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:626)
 at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:570)
 at
org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:482)




pojo类为:
public class GraAppInfo{
             private College college;
}

action 类为
public class GraAppAction
    extends BaseAction {
       public ActionForward add(ActionMapping mapping, ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response) throws Exception {

        graInfo.setCollege(new College());\\必须从数据库找到college这个对象,而不能新生成
       
        graInfo.getCollege().setID(graForm.getCollegeID());
        graInfo.setAppStatus(Integer.parseInt("0"));
      service.addGraduateApp(graInfo);
}

public class GraAppServiceImpl extends BaseServiceImpl
    implements GraAppService{

    public boolean addGraduateApp(GraAppInfo info)
    {
        this.getBaseDAO().save(info);
        return true;
    }
}
dao类save方法为
    getHibernateTemplate().save(obj);

当cascade="all",插入new college 除了id和原来的记录一样,其他的字段全部都被更新,为null
当cascase=“insert”,插入new college 只会把它的id插入grainfo表中,其他字段不变。

17、java.sql.SQLException: Unable to convert between java.lang.Integer and BLOB.
因为
        <property
            name="province"
            type="com.xindeco.business.pojo.SysCode"//不能用复杂类,
            update="true"
            insert="true"
            access="property"
            column="provinceId"
        />
应该改为
            <many-to-one
            name="province"
            class="com.xindeco.business.pojo.SysCode"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="provinceId"
        />

18、javax.servlet.jsp.JspException: Cannot create iterator for this collection
 at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:265)
jsp文件如下:
   <logic:notEmpty name="graduateList" >
   <logic:iterate id="graduate"  name="graduateList" >
   </ogic:notEmpty >
   </ogic:iterat>
graduateList是一个类,而logic:iterator要求必须是ArrayList,HashSet....这样的集合类,而graduateList中一个属性是ArrayList或HashSet的
应改为:
<logic:notEmpty name="graduateList" property="items">
 <logic:iterate id="graduate"  name="graduateList" property="items" >
 </ogic:notEmpty >
  </ogic:iterat>


19、2006-05-11 17:13:37,468 ERROR com.xindeco.business.web.action.GraAppAction - com.xindeco.business.web.action.GraAppAction@bc22eb
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed

SysUser user= (SysUser) request.getSession().getAttribute(WebConstants.SESSION_USER);
        System.out.println(user.getRole().getRoleName());
当hibernate session取出数据放到http session时,
由于sysuser中role的lazy=“true”,所以没有将RoleName放到http session中,当System.out.println(user.getRole().getRoleName());
时,虽然http session还开着, hibernat seesion已经关闭
        <many-to-one
            name="role"
            class="com.xindeco.business.pojo.SysRole"
            lazy="false"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="roleID"
        />
20、Association references unmapped class: com.xindeco.workflow.WFNode
因为application.xml文件中没有配置<mapping resource="com/xindeco/workflow/WFNode.hbm.xml"/>
系统找不到WFNode

        < set
            name
= " nodes "
            table
= " WF_ROLENODES "
            lazy
= " true "
            inverse
= " false "
            cascade
= " none "
            sort
= " unsorted "
        
>

              
< key
                  column
= " roleID "
              
>
              
</ key >

                 
< many - to - many
                  
class = " com.xindeco.workflow.WFNode "
                  column
= " nodeId "
                  outer
- join = " auto "
               
/>
               

        
</ set >
posted @ 2006-04-16 15:54 aimy 阅读(2705) | 评论 (1)编辑 收藏

1。当地址为href="/myRegister/myRegister.do?method=listRegister&&size=10&&&start=5"
   可以通过下面方法分别取到size&&start:
    Map requestMap = request.getParameterMap();
    String  size = requestMap.get("size");
    String start =requestMap.get("start");

2。checkbox取相同名字,则表单上得到的是一个数组。
      <tr>
              <td><input type="checkbox" value="<%=register.getId()%>" id="id"/></td>
               <td><%=register.getName()%></td>
               <td><%=register.getPassword()%></td>
                </tr>

    问题一:表单提交以后,form的对象是什么??
    问题二:如何利用request取到id的值数组??
    问题二的解决方法为将id值用","连成字符串,将字符串传递给action以后再进行分解.具体的解决为:(实现批量删除)
    delete.jsp:
<%@page import="com.xindeco.core.pagination.PaginationSupport" %>
<%@page import="com.xindeco.myregister.pojo.MyRegisterInfo"%>
<%
   PaginationSupport support = (PaginationSupport)request.getAttribute("registerList");
   List registerList=support.getItems();
    %>
<script>
function concatValue(obj,delimiter) {//将id用,串成string
     if(!obj) {
          return false;
     }
     if(!obj.length&&obj.checked) {
          return obj.value;
     }
     var str='';
     for(var i=0;i<obj.length;i++) {
         if(obj[i].checked) {
              str=str+obj[i].value;
              str=str+delimiter;
         } 
     }
     if(str.length>0) {
         return str.substring(0,str.length-1);
     }
     return str;     
 }
 function dele(obj)
 {
     var str = concatValue(obj,',');
     location.href('/myRegister/myRegister.do?   method=deleteRegister&&ids='+str);
  }
</script>
<html ><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
    <form action="/myRegister/myRegister.do?method=listRegister">
        <table id="detailTable" width="100%" border="0" >
              <tr>
              <td></td> <td>姓名</td><td>password</td>
              </tr>
           <%
           for(int i=0;i<registerList.size();i++)
           {
               MyRegisterInfo register= (MyRegisterInfo) registerList.get(i);
           %>
              <tr>
                  <td><input type="checkbox" value="<%=register.getId()%>" id="id"/></td>
                  <td><%=register.getName()%></td>
                  <td><%=register.getPassword()%></td>
                  </tr>
   <% }%>
         <tr><td><input type = "button" onclick="dele(document.getElementsByName('id'))" value="删除"></input></td></tr>
        </table>
    </form>
</body>
</html>

action中的方法:
      String ids = req.getParameter("ids");
          String[] idList = ids.split(",");
          if(idList!=null){
              Long[] idLong = new Long[idList.length];
              for (int i = 0; i < idList.length; i++) {
                  idLong[i] = Long.valueOf(idList[i]);
              }
          if(service.deleteRegister(idLong)) return mapping.findForward("success");
          }

其中deleteRegister的方法体为:

public boolean deleteRegister(Long[] ids)
    {
       MyRegisterDAO dao = (MyRegisterDAO) this.getBaseDAO();
       for(int i=0;i<ids.length;i++) {
            dao.remove(MyRegisterInfo.class,ids[i]);
        }
        return true;
    }


dao.remove的方体为
   public void remove(Class clazz, Serializable id) {
        getHibernateTemplate().delete(get(clazz, id));
    }

在这过程中我发现了long和Long的最大差别:Long是serializable类型,并且从string转化的过程也不同.
   long simple = Long.ParseLong(str);
   Long objLong = Long.valueOf(str);

posted @ 2006-04-15 15:34 aimy 阅读(139) | 评论 (0)编辑 收藏

    1。action类中的方法:
            public ActionForward updateRegister(ActionMapping mapping,ActionForm form,HttpServletRequest req,
          HttpServletResponse res)throws Exception{
          MyRegisterInfo register = new MyRegisterInfo();
          MyRegisterActionForm registerForm = (MyRegisterActionForm) form;
          this.beanCopy(register,form);
          MyRegisterService service =  (MyRegisterService) this.getBean("myRegisterService");
          if (service.updateRegister(register))
              {
              PageInfo page = new PageInfo(req.getParameterMap());
              req.setAttribute("registerList",service.listRegister(page));
              return  mapping.findForward("list-ok");

          }
        
  2。sevice中的方法体为
      public boolean updateRegister(MyRegisterInfo myRegisterInfo)
        {
        MyRegisterDAO dao = (MyRegisterDAO) this.getBaseDAO();
        dao.update(myRegisterInfo);
        return true;
    }  
  3。dao中的方法体为
    public void update(Object obj) {
        getHibernateTemplate().saveOrUpdate(obj);
    }
 
  4。因为registerform的类为四个属性的getter和setter
      private String name;
      private String password;
      private String repassword;
      private Long id;
     //一开始因为少了id,从页面上传来的form没有id,调用saveOrUpdate()方法时,hibernate调用的sql语句是insert,而不是update语句,因此页面上原来的行不仅还在,而且还不断有新行增加。
     
 

 

posted @ 2006-04-14 16:16 aimy 阅读(223) | 评论 (0)编辑 收藏

<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<script>
     function checkall(all,one)
{

    var obj = document.getElementsByName(one);
    
    if(!obj) return false;
    if(!obj.length&&all.checked) return obj;
    for(var i=0;i<obj.length;i++)
     {
      alert(all.checked);
      obj[i].checked=all.checked
      alert(obj[i].checked);
     }
    return true;
  

     function checkone(obj)
{
 alert('hello');
 alert(obj.name);
 return false;
}
 </script>
</head>
<body bgcolor="#ffffff">
 <form>
  <input type="checkbox" onclick="return checkone(this)" name="mm"/><br>//有return,无法选择这个checkbox
  <input type="checkbox" onclick="checkone(this)" name="mm"/><br>//无论是否返回false,都可以选择这个checkbox
  <input type="checkbox" onclick="checkone(this)" name="mm"/><br>
        <input type="checkbox" onclick="checkall(this,'mm')" name="mmAll"/><br>
    
    </form>
<table border="0">
</table>
</body>
</html>
注意点:
1、双引号里面只能含单引号
2、只有一个对象时,只能用getElementbyId(当id属性没有赋值时,name可以当作id属性),如果是一个数组对象,就要用getElementsByName.比较下面的文件:
function selectAll(obj,flag) {
 if(!obj) {//对象可以是null,但单个对象没有length的属性,所以还要判断length
  return false; 
 }
 if(!obj.length) {//如果是单个对象,不是对象数组
  obj.checked=true;
  return true;
 }
 for(var i=0;i<obj.length;i++) {
  obj[i].checked=flag;
 }
 return true; 
}

/**
* Test selected one item or not
* @author rainshow
*/
function selectOne(obj) {
 if(!obj) {
  return false;
 }
 if(!obj.length&&obj.checked) {
  return obj;
 }
 var count=0;
 var checkedObj;
 for(var i=0;i<obj.length;i++) {
  if(obj[i].checked) {
   checkedObj=obj[i];
   count++;
  }
 }
 if(count==1) {
  return checkedObj;
 }
 return false;
}

2。<a href="http://localhost:8080/myRegister/myRegister.do?method=listRegister&&size=<%=support.getPageSize()%>&&Page=<%=support.getPreviousIndex()%>">上一页</a>
注意点:<%变量%>直接放在“”字符串内,不用连接“+<%变量%>+”
错误做法:<a href="http://localhost:8080/myRegister/myRegister.do?method=listRegister&&size="+<%=support.getPageSize()%>+"&&Page="+<%=support.getPreviousIndex()%>">上一页</a>
3.区别页面的跳转:
定向到其他页面
<script>
location.href("http://localhost:8080/new-register.jsp");
</script>
相当与<%response.sendRedirect("http://localhost:8080/new-register.jsp")%>
而windows.open(“http://localhost:8080/new-register.jsp”)则开出另一个窗口

posted @ 2006-04-13 12:52 aimy 阅读(3657) | 评论 (2)编辑 收藏