Questions tagged [hibernate-restrictions]

10 questions
1
vote
0 answers

Using ArrayList in Hibernate Restrictions.in()
Restrictions.in(String propertyName,Collection values) work fine if an ArrayList of String or Integer or even simple array is passed to it.However I want to pass ArrayList of DTO object where DTO has a mapping file defined in hibernate.cfg.xml. Here…
Zafar Nasim
  • 529
  • 1
  • 6
  • 10
0
votes
0 answers

org.hibernate.MappingException: Could not locate CollectionPersister for role : com.jbk.Entity.Product.productName

Whenever, I try to run below method it is giving above error public static List productGettingWithSize(int size) { Session session = factory.openSession(); List list = null; try { Criteria…
0
votes
0 answers

org.hibernate.MappingException: Could not locate CollectionPersister for role : com.jbk.Entity.Product.productName

`Whenever, I try to run below method it is giving above error public static List productGettingWithSize(int size) { Session session = factory.openSession(); List list = null; try { Criteria…
0
votes
1 answer

How do I change this Hibernate code with org.hibernate.criterion.Restrictions code to JPA. Is there any alternatives to Restrictions API?

Does anyone know how to change this to JPA? and if there are any alternatives for the org.hibernate.criterion.Restrictions API? Thank you! public void initShowAFilterCriteria (Criteria crit, ShowingAFilter filter, Object user) { if(filter ==…
0
votes
2 answers

Hibernate criteria with a combination of AND/OR

I have to build a condition as below in the code. The number of conditions added as a mix of AND/OR may vary with the same parameters. WHERE ( (name=? AND number=?) ) OR ( (name=? AND number=?) ) OR (...) OR (...) I tried below code in a loop --…
Harish
  • 638
  • 1
  • 10
  • 20
0
votes
1 answer

Hibernate Restriction to search with like clause in list

I need help with hibernate criteria restriction. As we know that we use IN restriction with list , i.e Criteria criteria = session.createCriteria(Student.class); List studentNames= new…
R Ram
  • 165
  • 1
  • 3
  • 14
0
votes
2 answers

Comparing two columns in Hibernate Criteria

I have a table in Postgre Database. The table has 2 timestamp format columns. I need those rows where one column timestamp is not equals the second column timestamp. For the below query I need the Hibernate criteria restrictions. select * from A…
0
votes
1 answer

How to set multiple criteria like SUM, MAX, AVG and print it in hibernate template

Hello, I am trying to get max, avg, sum of "productCount". I write this code. I can not find what to do to fix this. Database query : select sum(product.PRODUCT_COUNT), avg(product.PRODUCT_COUNT), max(product.PRODUCT_COUNT) from product where…
0
votes
0 answers

Hibernate 5 CriteriaBuilder query by id

Since Hibernate 5 no longer supports createCriteria, I cannot figure out how to replace the old session.createCriteria(className.class).add(Restrictions.idEq(id)).list(); idEq() part with CriteriaBuilder. CriteriaBuilder equal method works only if I…
0
votes
2 answers

I want to remove completed orders from a list

In my App I have List of Orders. I want to remove completed orders from that list. that means the status = Completed.There are more two status. so I try this. Session s = HibernateSession.getSession(); Criteria c = HibernateSession.createCriteria(s,…