I have a column in mysql “description ”
which value is like “this is a description of some of the products we have the list of the products is big enough..”
now i want to retrieve it from mysql in to java but only first 10 characters with hibernate criteria
from below i can get this above value from mysql ,but i just want to get only first 10 like “”this is a description of some of the products” not more than this
any way of doing it in hibernate .
Patients patients = null;
session = sessionFactory.openSession();
Criteria crit = session.createCriteria(Patients.class);
List rsList = crit.list();
for(Iterator it=rsList.iterator(); it.hasNext();)
{
patients = (Patients)it.next();
thanks
One way of doing this is to create a NamedQuery and create a select statement with something like this :
select left(<mycolumn>,10) as <myColumn10> from <mytable>then you call this NamedQuery from your code.
Here is an example on how to use a NamedQuery: NameQuery Example