1

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

Moritz Petersen
  • 12,902
  • 3
  • 38
  • 45
Naresh
  • 333
  • 1
  • 2
  • 9

1 Answers1

1

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);
Moritz Petersen
  • 12,902
  • 3
  • 38
  • 45