wood burning stoves*
The moose likes Other Java Products and Servers and the fly likes eql-ql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "eql-ql" Watch "eql-ql" New topic
Author

eql-ql

Azizur Rehman
Greenhorn

Joined: Oct 24, 2005
Posts: 1
Hi,

I have three table to join.I am using cmp with ejb-ql and xdoclet
1)ACLUSER

acluserid(pk),name,password,usertype,datecreated

2)ACLROLES

roleid(pk),name,description

3) ACL_USER_ROLE

acluserroleid(pk)
acluserid(fk)
aclroleid(fk)
hasaccess
with_grant_option

I have to right three query one for username,one for roleid,rolename,and thired for whole ACL_USER_TABLE where im passing the role id as a parameter in ejb-ql by setting the value.But its not working.plz help me

java code using sql is

conn = getConnection();
int i=0;
String userName="";
String Query="SELECT LOGINNAME FROM ACL_USER WHERE ACLUSERID="+userId;
ps2=conn.prepareStatement(Query);
resultset=ps2.executeQuery();
System.out.println("The updated value of EditAddUserRole is=");
if(resultset.next())
userName=resultset.getString(1);
resultset.close();
Query="SELECT ACLROLEID,NAME FROM ACL_ROLES ORDER BY NAME";
ps = conn.prepareStatement(Query);
rs = ps.executeQuery();
System.out.println("The updated value of EditAddUserRole is=");
boolean hasAccess=false;
ps1=conn.prepareStatement("SELECT * FROM ACL_USER_ROLE " +
"WHERE ACLROLEID=? AND ACLUSERID="+userId);
while(rs.next())
{

i = 1;
int roleId = rs.getInt(i++);
String roleName = rs.getString(i++);
ps1.setInt(1,roleId);
resultset=ps1.executeQuery();
if(resultset.next()) hasAccess=true;
else hasAccess=false;
resultset.close();
//System.out.println(hasAccess +"--"+roleId);
roleVO=new RoleVO(roleId,roleName,hasAccess);
al.add(roleVO);
//System.out.println("al="+al.size());
}// end of while

roleVO1=new RoleVO(al,userName);
System.out.println("The updated value of EditAddUserRole is=");



ejb code in session facade is


public RoleInfo editAddUserDetail(Integer aclUserId)throws EJBException
{

AclUserInfo userInfo=new AclUserInfo();
RoleInfo roleInfo=new RoleInfo();
RoleInfo roleInfo1=new RoleInfo();
UserRoleInfo userroleInfo=new UserRoleInfo();
ArrayList al=new ArrayList();
boolean hasAccess=false;
try
{
Collection coll=null;
Collection col=null;
AclUserLocalHome userHome=AclUserUtil.getLocalHome();
AclUserLocal user=userHome.findByAclUserId(aclUserId);
String name=user.getLoginName();

System.out.println("The value of USERNAME="+ name);
AclRoleLocalHome roleHome=AclRoleUtil.getLocalHome();
AclRoleLocal role=null;
coll=roleHome.findAll();
Iterator itr=coll.iterator();
//Integer roleId=userrole.getAclUserRoleId();
while(itr.hasNext())
{

AclRoleLocal role1=(AclRoleLocal) itr.next();
Integer roleId=role1.getAclRoleId();
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@##################The value of role id is="+ roleId);
String roleName=role1.getName();

// AclRoleLocal rolel=new AclRoleLocal(role1.getAclRoleId());


AclUserRoleLocalHome userroleHome=AclUserRoleUtil.getLocalHome();
//AclUserRoleLocal userrole=userroleHome.ej.findByUserId(aclUserId);
//Integer a1=
// userrole.setAclRole((role1));
//userrole.setAclRole(role1);

//userrole.getAclRole();
if(itr.hasNext())
hasAccess=true;
else
hasAccess=false;
roleInfo=new RoleInfo(roleId,roleName,hasAccess);

al.add(roleInfo);

}// end of while
roleInfo1=new RoleInfo(al,name);
System.out.println("The updated value of EditAddUserRole is=");


}catch(Exception e)
{
System.err.println(e);
}
return roleInfo1;
}



ejb query is


* XDoclet-based CMP 2.x entity bean. This class must be declared
* public abstract because the concrete class will
* be implemented by the CMP providers tooling.
*
* To generate EJB related classes using XDoclet:
*
*- Add Standard EJB module to XDoclet project properties
*- Customize XDoclet configuration
*- Run XDoclet
*
* Below are the xdoclet-related tags needed for this EJB.
*
* @ejb.bean name="AclUserRole"
* display-name="Name for AclUserRole"
* description="Description for AclUserRole"
* jndi-name="ejb/AclUserRole"
* type="CMP"
* cmp-version="2.x"
* view-type="both"
* primkey-field = "aclUserRoleId"
*
* @ejb.persistence table-name = "ACL_USER_ROLE"
* @jboss.persistence table-name = "ACL_USER_ROLE"
*
* @jboss.unknown-pk class = "java.lang.Integer" column-name = "ACLUSERROLEID" auto-increment = "yes"
* @jboss.entity-command name = "mysql-get-generated-keys"
*
* @ejb.util generate="physical"
*
* @ejb.value-object
*
*
* @ejb.finder
* signature = "com.vrs.user.interfaces findByUserId(java.lang.Integer aclUserId)"
* query = "SELECT OBJECT(user) FROM AclUserRole user WHERE user.aclUser.aclUserId=?1" and user.aclRole.aclRoleId=? view-type="both"
*
*
*/


now i want to pass the value of aclRoleId using session bean.


Plz help me ASAP

Thanking You
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: eql-ql