2

I referred to the below one for adding a specific columns to be returned in hibernate. How to return an entity with chosen columns using Criteria

However in mycase the exclusion is small so i would like to see if i can give the list of columns to be excluded in the result.

Is there a optimal way to do it in hibernate?

Community
  • 1
  • 1
linux developer
  • 821
  • 1
  • 13
  • 34

1 Answers1

4

Note: There is no way to provide exclusions in Hibernate Criteria.

Several other ways of inclusions are below. It is totally your choice.

  1. One way of doing this is creating a light weight hibernate mapping object with only columns that are required.
  2. Use HQL to get the columns that you need like this ' Select c.col1,c.col2 from Columns c'
  3. Construct HQL at run time, have a template prepared like below

    'Select ' + userDefColumns + ' from Columns c'; // pass the userDefColumns at run time.

  4. As mentioned here

Community
  • 1
  • 1
Zeus
  • 6,386
  • 6
  • 54
  • 89