C
C
ClaraOswald2016-05-29 21:04:45
Hibernate
ClaraOswald, 2016-05-29 21:04:45

How to get records in hibernate whose id is equal to the values ​​from the array?

How to get records in hibernate whose id is equal to the values ​​from the array?
this is how you can get a specific record:
criteria.add(Restrictions.eq("id", id));
for example, I have an array, and I could do it like this:

int []mas= {1, 2, 3, 4, 5, 6};
criteria.add(Restrictions.eq("id", mas));

but as they explained to me, it won’t work like that, but they didn’t explain how it should be that it would work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Myvrenik, 2016-05-29
@ClaraOswald

Use Restrictions.in() instead of Restrictions.eq()
criteria.add(Restrictions.in("id", mas));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question