Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:23:26+00:00 2026-06-11T00:23:26+00:00

I have DLawUserMaster table which has UserID, LoginId and password field. Among them UserId

  • 0

I have DLawUserMaster table which has UserID, LoginId and password field. Among them UserId and LoginId are composite key. When user try to login using userID and password, I want to validate user and get userID to store it in session for further use in application.

I have tried to get userID using query in netbeans HQL query editor as below.

  1. select count(*) from DLawUserMaster user where user.id.loginId=’admin’ and user.password=’admin’

  2. select count(user.id.loginId) from DLawUserMaster user where user.id.loginId=’admin’ and user.password=’admin’

  3. select user.id.userId from DLawUserMaster user where user.id.loginId=’admin’ and user.password=’admin’


Long | Long | Long | Char

Blank | Blank | Blank | Blank

blank means empty but it shows 1 row(s) selected.

Here is the code
UserMaster.java

public class DLawUserMaster  implements java.io.Serializable {


 private DLawUserMasterId id;
 private String userFirstName;
 private String userMiddleName;
 private String userLastName;
 private String password;

public DLawUserMaster() {
}



public DLawUserMaster(DLawUserMasterId id, String userFirstName, String userMiddleName, String userLastName, String password, String address1, String address2, String address3, String city, String state, String pincode, String mobileNo, String stdCode, String phoneNo, String emailId, String hintQuestion, String hintAnswer, Date registrationDate, Date expiryDate, Boolean activate, Integer noOfClientAllowed, Date createdDate, Date modifiedDate) {
   this.id = id;
   this.userFirstName = userFirstName;
   this.userMiddleName = userMiddleName;
   this.userLastName = userLastName;
}

public DLawUserMasterId getId() {
    return this.id;
}

public void setId(DLawUserMasterId id) {
    this.id = id;
}
public String getUserFirstName() {
    return this.userFirstName;
}

public void setUserFirstName(String userFirstName) {
    this.userFirstName = userFirstName;
}
public String getUserMiddleName() {
    return this.userMiddleName;
}

public void setUserMiddleName(String userMiddleName) {
    this.userMiddleName = userMiddleName;
}
public String getUserLastName() {
    return this.userLastName;
}

public void setUserLastName(String userLastName) {
    this.userLastName = userLastName;
}
public String getPassword() {
    return this.password;
}

public void setPassword(String password) {
    this.password = password;
}
}

UserMasterID.java

public class DLawUserMasterId  implements java.io.Serializable {


 private long userId;
 private String loginId;

public DLawUserMasterId() {
}

public DLawUserMasterId(long userId, String loginId) {
   this.userId = userId;
   this.loginId = loginId;
}

public long getUserId() {
    return this.userId;
}

public void setUserId(long userId) {
    this.userId = userId;
}
public String getLoginId() {
    return this.loginId;
}

public void setLoginId(String loginId) {
    this.loginId = loginId;
}


public boolean equals(Object other) {
     if ( (this == other ) ) return true;
     if ( (other == null ) ) return false;
     if ( !(other instanceof DLawUserMasterId) ) return false;
     DLawUserMasterId castOther = ( DLawUserMasterId ) other; 

     return (this.getUserId()==castOther.getUserId())
&& ( (this.getLoginId()==castOther.getLoginId()) || ( this.getLoginId()!=null &&     castOther.getLoginId()!=null && this.getLoginId().equals(castOther.getLoginId()) ) );
}

public int hashCode() {
     int result = 17;

     result = 37 * result + (int) this.getUserId();
     result = 37 * result + ( getLoginId() == null ? 0 :     this.getLoginId().hashCode()      );
     return result;
} 
}

Can anyone give me suggestion to get userID value. Also about how to use count in it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:23:28+00:00Added an answer on June 11, 2026 at 12:23 am

    First thing that netbeans shows

    Long | Long | Long | Char
    Blank | Blank | Blank | Blank
    

    it doesn’t matter as it is returning proper value when u use

    Query q = session.createQuery(SQL_QUERY);
    list = q.list()

    in list it will return no of count.

    Second, when we are using composite key then we have use primary key class’s object defined in bean

    If you need result through query
    select client.id.clientId from DLawClientMaster client where client.id.userId=’1′ and client.id.clientId=’1′

    If you are using criteria API then

    Criteria criteria = session.createCriteria(DLawClientMaster.class);
    criteria.add(Restrictions.eq("id.userId", client.getId().getUserId()));
    criteria.setProjection(Projections.max("id.clientId"));
    List list = criteria.list();
    

    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a table called person. which has personid and contactid. if a person is
Have deployed numerous report parts which reference the same view however one of them
Have a simple one-off tasks which needs a progress bar. OpenSSL has a useful
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have 2 questions : A computer with 32-bit address uses 2-level page table (9
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
Have a really weird one here. The app has two targets, just to be
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.