0

I've stored the full name of the individual as firstName, middleName & lastName differently on the datastore.

The user enters the full name to search the individual. The problem is I want to search firstName, middleName & lastName combinedly.

And, I can't make the tokens of full name as there may be embedded spaces. Please help me. This is killing me.

2 Answers2

0

In your model make a new getter

Public String getFullName(){
    return firstName+" "+middleName + " " + lastName;
}

Now use this in hibernate

hql="From User u where fullName="+fullName;
prem30488
  • 2,828
  • 2
  • 25
  • 57
0

You can use @Formula

@Column(name = "first_name")
private String firstName;

@Column(name = "last_name")
private String lastName;

@Formula(value = "first_name + ' ' + last_name")
private String name;

then you can query on the name property as if it was a column in your table

jpprade
  • 3,497
  • 3
  • 45
  • 58