下面是主要涉及的dwr和hibernate配置文件
A.hibernate.xml文件:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">Finance</property> <!--JNDIName-->
<property name="hibernate.use_sql_comments">true</property> <!--指定在SQL语句中输出便于调试的注释信息-->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> <!--指定数据库使用的SQL方言-->
<property name="show_sql">true</property> <!--当show_sql属性为true时,表示当程序运行时在控制台输出SQL语句.默认为false-->
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<!--指定持久化类映射文件-->
<mapping resource="com/fin/bmys/budget/Bbrpt.hbm.xml"/>
<mapping resource="com/fin/bmys/budget/Xtdwsb.hbm.xml" />
<!-- 平台 -->
<mapping resource="com/fin/auth/Xtdwuser.hbm.xml" />
<mapping resource="com/fin/platform/Xtdwb.hbm.xml" />
<mapping resource="com/fin/platform/Xtdmlx.hbm.xml" />
<mapping resource="com/fin/platform/Xtbmdwkm.hbm.xml" />
<mapping resource="com/fin/platform/Xtbmdwkmsr.hbm.xml" />
<mapping resource="com/fin/platform/Xtbmdwkm06.hbm.xml" />
<!-- 项目管理 -->
<mapping resource="com/fin/xmgl/Dtxmjbxx.hbm.xml" />
<mapping resource="com/fin/xmgl/Dtxmjbxxdmlx.hbm.xml" />
<mapping resource="com/fin/xmgl/Dtxmjbxxmx.hbm.xml" />
</session-factory>
</hibernate-configuration>
通过此文件中的<mapping>标签找到每一模块每一操作所对应的*.hbm.xml文件;
B. Xtdwuser.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 package="com.fin.auth">
<class name="Xtdwuser" table="XTDWUSER">
<composite-id name="id" class="XtdwuserKey" unsaved-value="any">
<key-property name="ysnf" column="YSNF" />
<key-property name="dwdm" column="DWDM" />
<key-property name="roledm" column="ROLEDM" />
<key-property name="username" column="USERNAME"/>
</composite-id>
<property name="xm" column="XM" />
<property name="pw" column="PW" />
</class>
</hibernate-mapping>
此文件中关系到表XTDWUSER,其表中的主键有YSNF, DWDM, ROLEDM, USERNAME;从而就产生了Xtdwuser.java与XtdwuserKey.java类文件,在XtdwuserKey.java类文件中主要的属性就是表中的主键字段,而Xtdwuser.java类文件中主要的属性主要是表中XM与PW字段.
C. XtdwuserKey.java文件:
package com.fin.auth;
import java.io.Serializable;
import com.fin.util.CBean;
import com.fin.auth.XtdwuserKey;
import com.wintruz.util.ObjUtils;
public class XtdwuserKey extends CBean implements Serializable{
private String ysnf;
private String dwdm;
private String roledm;
private String username;
public String getDwdm() {
return dwdm;
}
public void setDwdm(String dwdm) {
this.dwdm = dwdm;
}
public String getRoledm() {
return roledm;
}
public void setRoledm(String roledm) {
this.roledm = roledm;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getYsnf() {
return ysnf;
}
public void setYsnf(String ysnf) {
this.ysnf = ysnf;
}
public boolean equals(Object obj)
{
if (obj == null) {
return false;
}
if (obj instanceof XtdwuserKey) {
XtdwuserKey that = (XtdwuserKey) obj;
return
ObjUtils.nullSafeEquals(that.getDwdm(),this.getDwdm())&&ObjUtils.nullSafeEquals(that.get Ysnf(),this.getYsnf())&&ObjUtils.nullSafeEquals(that.getRoledm(),this.getRoledm())&& ObjUtils.nullSafeEquals(that.getUsername(), this.getUsername());
}
return false;
}
public int hashCode()
{
return this.getYsnf().hashCode() ^ this.getDwdm().hashCode() ^ this.getRoledm().hashCode() ^ this.getUsername().hashCode();
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("ysnf:");
sb.append(this.getYsnf());
sb.append("/n");
sb.append("dwdm:");
sb.append(this.getDwdm());
sb.append("/n");
sb.append("roledm:");
sb.append(this.getRoledm());
sb.append("/n");
sb.append("username:");
sb.append(this.getUsername());
return toString();
}
}
D. Xtdwuser.java文件:
package com.fin.auth;
import com.fin.util.CBean;
import com.wintruz.util.ObjUtils;
public class Xtdwuser extends CBean implements IXtdwuser{
private XtdwuserKey id;
private String xm;
private String pw;
public Xtdwuser()
{}
public Xtdwuser(XtdwuserKey id)
{
this.id=id;
}
public XtdwuserKey getId() {
return id;
}
public void setId(XtdwuserKey id) {
this.id = id;
}
public String getPw() {
return pw;
}
public void setPw(String pw) {
this.pw = pw;
}
public String getXm() {
return xm;
}
public void setXm(String xm) {
this.xm = xm;
}
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (obj instanceof IXtdwuser)
{
IXtdwuser that = (IXtdwuser) obj;
return (ObjUtils.nullSafeEquals(that.getId(), this.getId()));
}
return false;
}
}
在此类中有属性XtdwuserKey类型的id,通过此属性可以与XtdwuserKey.java类连接.
E. Dwuserxx.java文件:
package com.fin.auth.logic;
import java.util.List;
import javax.servlet.http.HttpSession;
import uk.ltd.getahead.dwr.WebContextFactory;
import com.fin.auth.Logon;
import com.fin.auth.Xtdwuser;
import com.fin.auth.XtdwuserKey;
import com.fin.auth.service.AuthService;
import com.wintruz.application.ServiceStatus;
public class Dwuserxx {
private AuthService authService;
public AuthService getAuthService() {
return authService;
}
public void setAuthService(AuthService authService) {
this.authService = authService;
}
public String[] GetYsnf()
{
return authService.listysnf();
}
public boolean CheckUser(String ysnf,String dwdm,String roledm,String username,String pw) throws Exception
{
Logon logon=new Logon();
logon=authService.checkUser(ysnf,dwdm,roledm,username,pw);
if(logon==null)
{
return false;
}
else
{
HttpSession session=WebContextFactory.get().getSession(true);
session.setAttribute("LogonInfo",logon);
return true;
}
}
public Object getLoginSession()
{
HttpSession session=WebContextFactory.get().getSession(true);
return (Object)session.getAttribute("LogonInfo");
}
public void DelSession()
{
HttpSession session=WebContextFactory.get().getSession(true);
session.removeAttribute("LoginInfo");
}
public Xtdwuser[] getListUser(String ysnf,String dwdm,String roledm)
{
try
{
return (Xtdwuser[])authService.listUserByDwdm(ysnf,dwdm,roledm).toArray(new Xtdwuser[]{});
}
catch(Exception e)
{
return null;
}
}
public ServiceStatus createUser(String ysnf,String dwdm,String roledm,String username,String xm,String pw)
{
try
{
XtdwuserKey uk=new XtdwuserKey();
uk.setYsnf(ysnf);
uk.setDwdm(dwdm);
uk.setRoledm(roledm);
uk.setUsername(username);
Xtdwuser xu=new Xtdwuser();
xu.setId(uk);
xu.setXm(pw);
xu.setXm(xm);
authService.createUser(xu);
return new ServiceStatus(ServiceStatus.OK);
}
catch(Exception e)
{
return new ServiceStatus(ServiceStatus.ERROR,e.getMessage());
}
}
public ServiceStatus updateUser(String ysnf,String dwdm,String editrole,String olduser,String edituser,String xm,String pw)
{
try
{
XtdwuserKey uk=new XtdwuserKey();
uk.setDwdm(dwdm);
uk.setYsnf(ysnf);
uk.setRoledm(editrole);
uk.setUsername(olduser);
XtdwuserKey uk1=new XtdwuserKey();
uk1.setDwdm(dwdm);
uk1.setYsnf(ysnf);
uk1.setRoledm(editrole);
uk1.setUsername(edituser);
Xtdwuser xu=new Xtdwuser();
xu.setId(uk1);
xu.setPw(pw);
xu.setXm(xm);
authService.updateUser(xu);
return new ServiceStatus(ServiceStatus.OK);
}
catch(Exception e)
{
return new ServiceStatus(ServiceStatus.ERROR,e.getMessage());
}
}
public ServiceStatus delUser(String ysnf,String dwdm,String roledm,String username)
{
try
{
authService.deleteUser(ysnf,dwdm,roledm,username);
return new ServiceStatus(ServiceStatus.OK);
}
catch(Exception e)
{
return new ServiceStatus(ServiceStatus.ERROR,e.getMessage());
}
}
public Xtdwuser getUser(String ysnf,String dwdm,String roledm,String username)
{
try
{
return authService.getUser(ysnf,dwdm,roledm,username);
}
catch(Exception e)
{
return null;
}
}
public Object[] getOptdw(String ysnf,String dwdm,String dmjc)
{
try
{
return authService.getoptdw(ysnf,dwdm,dmjc).toArray(new Object[]{});
}
catch(Exception e)
{
return null;
}
}
public ServiceStatus updateUser2(String ysnf, String dwdm, String editrole,String olduser, String edituser, String xm, String pw)
{
try
{
List a= this.getYearByUser(dwdm, editrole, olduser);
XtdwuserKey uk = new XtdwuserKey();
uk.setDwdm(dwdm);
uk.setUsername(olduser);
uk.setYsnf(ysnf);
uk.setRoledm(editrole);
XtdwuserKey uk1 = new XtdwuserKey();
uk1.setDwdm(dwdm);
uk1.setUsername(edituser);
uk1.setRoledm(editrole);
Xtdwuser xu = new Xtdwuser();
xu.setId(uk1);
xu.setPw(pw);
xu.setXm(xm);
for(int i=0;i<a.size();i++)
{
uk1.setYsnf(a.get(i).toString());
authService.updateUser(xu);
}
return new ServiceStatus(ServiceStatus.OK);
}
catch(Exception e)
{
return new ServiceStatus(ServiceStatus.ERROR,e.getMessage());
}
}
// 按要求把所有年份的密码改一致中使用到的方法 2007/7/30
public List getYearByUser(String dwdm,String roledm,String username)
{
return this.authService.getYearByUser(dwdm, roledm, username);
}
}
这是登录中涉及的所有方法!