java - Is there a method in hibernate to capitalize first letter of a string -


is there method in hibernate converts 1st letter of each word in string uppercase.

ex: firstname middlename lastname

to: firstname middlename lastname

if not, please tell how in java, don't want use libraries.

solution:

solved using following hql query.

string hql = "select concat(concat(upper(substring(personfirstname,1,1)), "                + " lower(substring(personfirstname,2))), ' ', "                + " concat(upper(substring(personmiddelname,1,1)), "                + " lower(substring(personmiddelname,2))), ' ', "                + " concat(upper(substring(personlastname,1,1)), "                + " lower(substring(personlastname,2)))) "                + " personmodel "; 

thanks.

i have written java program solves problem using methods available in string class

public static void main(string[] args) {         string test = "firstname middlename lastname";         string array [] = test.split(" ");         stringbuilder builder = new stringbuilder();         (int = 0; i<array.length; ++) {             builder.append(array[i].touppercase().charat(0) + array[i].substring(1, array[i].length()));             builder.append(" ");         }         system.out.println(builder.tostring());     } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -