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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:21:16+00:00 2026-06-09T23:21:16+00:00

Currently, I have a table that has a column which has a datatype enum.

  • 0

Currently, I have a table that has a column which has a datatype enum. My question is can I execute a IN query on this column?

For example:

enum Gender { MALE, FEMALE, GAY };
Table Student (
  String name;
  Gender gender;
)

Can I execute:

SELECT * FROM Student WHERE gender IN ('MALE', 'FEMALE');

Note that I use string as the parameter for in, but I’m getting:

Caused by: java.lang.IllegalArgumentException: Parameter value [('MALE')] did not match expected type [Gender]

Is there a workaround on this issue?

Thanks,

czetsuya

  • 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-09T23:21:17+00:00Added an answer on June 9, 2026 at 11:21 pm

    Since string values are not recognised, execute the following code (Assuming you have used Enum with default EnumType):

    SELECT * FROM Student WHERE gender IN (0,1);
    

    If using EnumType.String

    Query query = session.createQuery(
        "SELECT s FROM Student s WHERE s.gender=:g1 or s.gender=:g2");
    query.setParameter("g1", Gender.MALE);
    query.setParameter("g2", Gender.FEMALE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a User table that has a toys_owned column that is an
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I currently have a table structure that looks something like this(some details omitted): ColumnName
I currently have a table with an id column that is being autoincremented and
I currently have a closure table used for hierarchical data that has 5 million
Currently I have a database object, vacancies which has a column (foreign key) CareerLevels.
I have daily scheduled task that queries a table which includes column named AttemptDate
I currently have a site with a table that has Lat/Long float columns, and
This is a complex one. But I have a table which has a DATETIME
I'm trying to normalize a mysql database.... I currently have a table that contains

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.