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

  • Home
  • SEARCH
  • 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 8347091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:15:04+00:00 2026-06-09T07:15:04+00:00

Background: I have a User entity. The User entity looks like: private String name;

  • 0

Background:
I have a User entity. The User entity looks like:

private String name;
private String address;
private List<Picture> pictureList; //The users pictures
private int rolesBitmask; //Is a bitmask for around 20 different roles
private int anotherBitmask; //Is similar bitmask as the roles
//
// Maybe 20 more fields..

I will have an AJAX search webpage that will perform JPQL queries on ALL these fields (well maybe not the pictures, but for the most of the fields).

For example, the web user might be search at a user with name like “An%”, lives on Address like “Pica%”, have roles “printer”, “admin”, “guest” and don’t care about the rest of the roles available. The “printer”, “admin” and “guest” roles is interpreted to the bitmask according to a predefined value.

My first question:

Is it a bad idea to do these kind of queries in only 1 JPQL / whatever query?

Second question:
If I decide to go on with these “complex” queries what about the performance (keep in mind that it is a AJAX webpage which might be a new database access every time the user is changing the form).

Third question:
In SQL I would do something like this to get all users with name, address and roles:

SELECT * FROM User WHERE (rolesBitmask & queryRoleBitmask) ^ queryRoleBitmask = 0 AND name LIKE 'An%' AND address LIKE 'Pica%';

As fas as I know, JPQL don’t support bitwise operations, so I have to use native queries or try to tranform it to a JPQL equivalent, but I do not know how I am supposed to do it. Do you?

Can you guide me here, maybe I have to throw this whole AJAX search web page idea in the thrashcan, or what do you think about it? What is the best practice when you dealing with many criterias?

Thanks in advance

  • 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-09T07:15:05+00:00Added an answer on June 9, 2026 at 7:15 am

    You can use a native SQL query for this.

    JPQL does not directly support bitwise operators, but if you are using EclipseLink you could the SQL operator.

    Select u from User u where SQL('((? & ?) ^ ?)', u.rolesBitmask, u.queryRoleBitmask, u.queryRoleBitmask) = 0 and u.name LIKE 'An%' AND u.address LIKE 'Pica%'
    

    http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#SQL

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

Sidebar

Related Questions

Background I have a payment page where the user can select from a list
I have a list of permissions defined like this: private List<PermissionItem> permissionItems; private ReadOnlyCollection<PermissionItem>
Problem Background: I have a 35K+ user members and growing fast. I am planning
I need to have background Music in my website, With user oN and OFF
I have the following code that sets a background if user has uploaded to
I have a service that performs background updates. I want to give the user
I have made Catifier.com recently, and once the user sets their own background image,
Background I have an array of objects (Users) defined and set as follows: //
Background We have a WinForms application with Entity Framework 4.2 code-first / FluentAPI using
Background: I have a custom user control based around a WPF TreeView. I've been

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.