I need to convert the below condition in JPA2,but found there is no alternative to Apply a constraint expressed in SQL with no JDBC parameters
Restrictions.sqlRestriction("{alias}.col3& " + value + " = " + value);
I tried using NativeQuery like the below sinppet where value is the parameter passing to the method:-
String sqlString="select * from myTable where col1=3600 and col2=true and col3&"+value+"="+value;
Query query=getSession().createNativeQuery(sqlString);
List<userDefClass> results = new ArrayList<userDefClass>();
results=(List<userDefClass>)query.getResultList();
For the above logic ,I am getting below error:-
"java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.pkg.userDefClass java.lang.RuntimeException
query.getResultList() is passing list of objects but not list of userdefClass objects.
ALso I tried using Typed Query but it is throwing SQL Grammer Exception.I guess its not parsing the bitwise '&' operator in the SQL String.
Please help.