📄 getuserlistmgrbean.java
字号:
package com.sample.ejb.sessionbean;
import java.math.BigDecimal;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.ejb.FinderException;
import javax.ejb.SessionBean;
import javax.naming.NamingException;
import com.sample.cmp.account.AccountLocal;
import com.sample.cmp.account.AccountLocalHome;
import com.sample.cmp.account.AccountUtil;
import com.sample.cmp.user.UserLocal;
import com.sample.cmp.user.UserLocalHome;
import com.sample.cmp.user.UserUtil;
import com.sample.model.service.dto.UserAccountDTO;
/**
*
* <!-- begin-user-doc --> A generated session bean <!-- end-user-doc --> *
<!-- lomboz.beginDefinition -->
<?xml version="1.0" encoding="UTF-8"?>
<lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz">
<lomboz:session>
<lomboz:sessionEjb>
<j2ee:display-name>GetUserListMgr</j2ee:display-name>
<j2ee:ejb-name>GetUserListMgr</j2ee:ejb-name>
<j2ee:ejb-class>com.sample.ejb.sessionbean.GetUserListMgrBean</j2ee:ejb-class>
<j2ee:session-type>Stateless</j2ee:session-type>
<j2ee:transaction-type>Container</j2ee:transaction-type>
</lomboz:sessionEjb>
</lomboz:session>
</lomboz:EJB>
<!-- lomboz.endDefinition -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.bean name="GetUserListMgr"
* jndi-name="GetUserListMgr"
* type="Stateless"
* transaction-type="Container"
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract class GetUserListMgrBean implements javax.ejb.SessionBean {
/**
* @throws NamingException
* @throws FinderException
* @throws RemoteException
* @ejb.interface-method
* view-type="remote"
**/
public UserAccountDTO[] getUserList() throws NamingException, FinderException, RemoteException{
ArrayList list = new ArrayList();
UserLocalHome userLocalHome = UserUtil.getLocalHome();
AccountLocalHome accountLocalHome = AccountUtil.getLocalHome();
Collection c = userLocalHome.findAll();
Iterator it = c.iterator();
while(it.hasNext())
{
UserAccountDTO userAccountDTO = new UserAccountDTO();
UserLocal user = (UserLocal) it.next();
Integer userID = user.getUserID();
Collection c1 = accountLocalHome.findByUserID(userID);
Iterator it1 = c1.iterator();
AccountLocal account = (AccountLocal) it1.next();
Integer accountID = account.getAccountID();
BigDecimal registrationFee = account.getRegistrationFee();
userAccountDTO.setUserAccountID(accountID);
userAccountDTO.setRegistrationFee(registrationFee);
userAccountDTO.setLoginName(user.getLoginName());
userAccountDTO.setName(user.getName());
userAccountDTO.setPassword(user.getPassword());
userAccountDTO.setEmail(user.getEmail());
userAccountDTO.setPhone(user.getPhone());
list.add(userAccountDTO);
}
//将ArrayList转化为UserAccountDTO数组
UserAccountDTO[] userDTOs = new UserAccountDTO[list.size()];
//返回UserAccountDTO数组
return (UserAccountDTO[])list.toArray(userDTOs);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -