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 8395003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:11:37+00:00 2026-06-09T20:11:37+00:00

I read somewhere that it’s impossible to get generic interface of a class in

  • 0

I read somewhere that it’s impossible to get generic interface of a class in run time. so how does hibernate do this? for example in a OneToMany mapping how does hibernate find out the Many part class (using annotation)?

class A{
    ...
    @OneToMany(mapped-by="a")
    public List<B> getBs(){ 
    ...
    }
}
  • 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-06-09T20:11:38+00:00Added an answer on June 9, 2026 at 8:11 pm

    I read somewhere that it’s impossible to get generic interface of a class in run time.

    It depends. You can’t ask an instance of a generic type what its type arguments are – but you can get that information from the metadata about classes, method return types etc.

    So for example, Method.getGenericReturnType returns a Type rather than a Class<?>, and that lets you get at the relevant information.

    Sample code:

    import java.lang.reflect.*;
    import java.util.*;
    
    public class Test {
    
        public static void main(String[] args) throws Exception {
            Method method = Test.class.getMethod("getList");
            Type returnType = method.getGenericReturnType();
            System.out.println(returnType); // java.util.List<java.lang.Integer>
            ParameterizedType parameterized = (ParameterizedType) returnType;
            System.out.println(parameterized.getActualTypeArguments()[0]);
        }    
    
        public List<Integer> getList() {
            return null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read somewhere that somebody could access a config value during run time but
I read somewhere that you would never run syncdb on a database, post its
I read somewhere that, overriding is the means by which you get polymorphism. Polymorphism
I read somewhere that synchronized(this) should be avoided for various reasons . Yet some
I read somewhere that it is disastrous to use free to get rid of
I read somewhere that EventHandler is a built-in generic type. Why is that so?
I read somewhere that you can interface to Naturally Speaking through the SAPI 4
I have read somewhere that the C++ standard does not allow something like enum
I read somewhere that ruby threads/fibre block the IO even with 1.9. Is this
I read somewhere that you can stop Magento from requiring two product descriptions... this

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.