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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:37:12+00:00 2026-05-30T20:37:12+00:00

I have two simple interfaces: public interface HasId<ID extends Serializable> extends Serializable { T

  • 0

I have two simple interfaces:

public interface HasId<ID extends Serializable> extends Serializable {
  T getId();
}

And

public interface HasLongId extends HasId<Long> {
  void setId(Long id);
}

Now, if I have a class:

public class Person implements HasLongId {
  private Long id;
  private String name;

  public Long getId() {
      return this.id;
  }

  public void setId(Long id) {
      this.id = id;
  }

  public String getName() {
      return this.name;
  }

  public void setName(String name) {
      this.name = name;
  }
}

And I instantiate a person, then pass it to BeanUtils I get strange behavior. For example sometimes setting id using BeanUtils works fine and other times, I get an exception because it can’t find the “write” method for Id. It seems that during reflection it finds a getter for a Serializable, but not a Long and it does not find a setter for the Serializable. It does not do this consistently, so I suspect that calling person.getClass().getDeclaredMethod(“id”) will not always return the same Method, but I could be wrong about that.

Anyway, this inconsistent behavior is really maddening because, for example, it will work in Eclipse, but not in Maven, or it will work for a long time and then with some unrelated change somewhere else it will stop working.

Clearly I don’t understand generics well enough to understand what is happening, but can anyone explain it to me and also explain how to work around it?

  • 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-30T20:37:14+00:00Added an answer on May 30, 2026 at 8:37 pm

    The version of Apache Commons BeanUtils I have used was not Java 5 aware, so it didn’t know about Generics, bridge methods, and so on. I believe that’s the problem, which version of BeanUtils are you using? and is it Java 5+ aware?

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

Sidebar

Related Questions

I have two simple tables in my database. A card table that contains Id,
I have two simple while loops in my program that I feel ought to
Let's say I have two simple models project t.string :title vote t.references :project t.integer
I have two very simple, identical UITableViews in my app that are populated with
I have two geo-spatial simple convex polygon areas, in latitudes and longitudes (decimal degrees)
Question is simple: I have two List List<String> columnsOld = DBUtils.GetColumns(db, TableName); List<String> columnsNew
Simple idea: I have two images that I want to merge, one is 500x500
I have two webapplication, one is a simple authenticationsite which can authenticate the logged
Let's say I have two strings like this: XABY XBAY A simple regex that
I have the following code that fills dataTable1 and dataTable2 with two simple SQL

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.