Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 284017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:25:21+00:00 2026-05-12T05:25:21+00:00

I have a JSF converter that I use for a SelectItem list containing several

  • 0

I have a JSF converter that I use for a SelectItem list containing several different entity types. In the getAsString() method I create the string as the class name suffixed with “:” and the ID.

MySuperClass superClass = (MySuperClass)value;
if(superClass != null) {
  return String.valueOf(superClass.getClass().getName()+":"+superClass.getId());
}

This allows me to load the correct entity in the getAsObject() on the way back from the UI by doing this :

String className = value.substring(0, value.indexOf(":"));
long id = Long.parseLong(value.substring(value.indexOf(":")+1));
Class<T> entitySuperClass = (Class<T>) Class.forName(className);
MySuperClass superClass = (MySuperClass)getEntityManager().find(entitySuperClass, id);

My problem is that my entity in getAsString() is a proxy. So instead of getting com.company.MyEntity when I do a getClass().getName() I am getting com.company.MyEntity_$$_javassist_48 so then it fails on the find().

Is there any way (aside from String manipulation) to get the concrete class name (eg. com.company.MyEntity)?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:25:22+00:00Added an answer on May 12, 2026 at 5:25 am

    Instead of superClass.getClass() try org.hibernate.proxy.HibernateProxyHelper.getClassWithoutInitializingProxy(superClass).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF web client and a Java client that both use the
I have a JSF application that makes much use of session-scoped variables. A new
I have a JSF page that is included in other JSF pages (basically a
I have several jsf pages. I need to add dynamic breadcrumbs to the header.xhtml.
I have a JSF application that uses mostly Richfaces. I would like to introduce
i have a JSF web application. I use Beans as Spring Beans (not JSF
We have JSF web application that generates XLS file and gives user link to
I have some JSF code that currently works (as shown below), and I need
Hi i have created a custom converter in jsf for combo box using h:selectOneMenu,
I have jsf application in which I have to use a facelet custom component

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.