Not able to get exact class name

186 Views Asked by At

I am not able to get exact className

My code is :

venue.getClass.getName();

It's giving output like:

com.venue.Venue_java_assist17_

I've to get output like exact classname: com.venue.Venue

1

There are 1 best solutions below

0
On BEST ANSWER

You can't directly get the class name, since it is a proxy. The only way to get the real class name is to strip of the suffix, e.g.:

String cn = "com.venue.Venue_java_assist17_";
System.out.println(cn.substring(0, cn.indexOf('_', cn.lastIndexOf('.'))));

If you are using Hibernate, you could use:

HibernateProxyHelper.getClassWithoutInitializingProxy(venue);