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 7796077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:15:39+00:00 2026-06-01T23:15:39+00:00

To avoid sql injections, normally Positional parameters and named parameters can be used in

  • 0

To avoid sql injections, normally Positional parameters and named parameters can be used in HQL as it demos here and stackoverflow also has samples. I want to know which steps can be taken when Criteria is used.Any help with sample codes or useful links please.

Edit
Also when we save a object then ? let’s say,the object may have a String variable and some one can assign a vulnerable sql query to it.

 myObject.setName(somevulnerablesql); session.save(myObject); 

In that case, should we have to check user input seperately before assigning to the object? or any other steps to avoid such sql injections ?

  • 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-01T23:15:40+00:00Added an answer on June 1, 2026 at 11:15 pm

    I’m quite sure that the Criteria-Object will create safe HSQL.

    You have to be careful with the Expression object. You may create a SQL-injection there.
    But take a look at the generated SQL: Hibernate show real SQL

    edit:
    Unless there is a huge bug in Hibernate, you don’t have to make sure, that your Strings are escaped before you save them. Hibernate works with prepared statements. So there is no string concatenation and no SQL-injection with the Hibernate-session.

    You may have to escape the output however after reading it with Hibernate. For example:
    You have a Entity User

    class User{
        String name;
    }
    

    And you call the user “‘ or 1=1;DROP DATABASE user;–” That string will be stored within the database.
    If you query the User with a Criterion object, you will find him (withou dropping the databse). If you query the User with the Expression object, you may drop the database (if you concenate Strings).

    If you output the user’s name to HTML you have to escape the output. Otherwise an user with a name "/><script>evilJavascript()</script> will be bad for your application.

    edit 2:
    take a look here: https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet

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

Sidebar

Related Questions

Can I avoid all SQL-injection attacks by using parameters? And don't worry about any
what is the best practice to avoid SQL injections. I have ran a McAfee
What is the best way from asp.net to avoid sql injections but at the
Am I doing this right? Will this help avoid sql injections? $deleteid = htmlspecialchars(strip_tags(mysql_real_escape_string($_POST['listid'])));
I know using prepared statements helps to avoid sql-injection. My problem is, that a
I would like to use following sql to avoid constructing sql dynamically: SELECT CommentID,
How can I avoid that a user starts the same program twice? The current
Trying to avoid the SomethingManager trap here... Let's say I'm going to write a
I'm trying to avoid the use of magic strings as much as I can,
I usually create parameterized queries in order to avoid SQL Injection attacks. However, I

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.