This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

eql-ql

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic