I am getting a cast exception while setting the name.
Object[] customers= customerRepository.getCustomerName(Id);
Customer row = new Custom
Try use it
customer[0].toString()
So no one bothered to read the exception message?
[Ljava.lang.Object; cannot be cast to java.lang.String
The leading [
indicates that the class is an array class.
What you're getting above is:
row.setName(((String) customers)[0]+" "+((String) customers)[1]);
Cast has precedence over array indexing.