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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:54:36+00:00 2026-06-15T12:54:36+00:00

My framework handles domain objects of any class. I need to be able to

  • 0

My framework handles domain objects of any class. I need to be able to shallow clone such a domain object instance foo, as if it implemented Cloneable (which it doesn’t) and I called Object.clone() on it which returns a shallow clone.

Things that do NOT work:

  • Force foo’s class to implement Cloneable and therefor the public method clone().
  • Through reflection call foo.clone() (to reach the protected method Object.clone()). It throws CloneNotSupportedException because foo‘s class does not implement Cloneable.
  • Serializing and deserializing foo: I need a shallow copy, not a deep copy.

Limitations:

  • foo‘s class is not know at compile time.
  • foo might have field that are not exposed as getters/setters.

Note: there are a couple of similar questions, but none seem to focus on a getting a shallow clone.

  • 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-15T12:54:37+00:00Added an answer on June 15, 2026 at 12:54 pm

    BeanUtils can clone non-cloneable Beans as long as they have setter/getters. Unfortunately Orika bean mapper doesn’t support mapping of private fields either.

    In the end, it may be easier for you to implement it based on reflection on your own (as hoaz is suggesting), since most libraries for bean mapping try to perform deep copies and you seem to have some special requirements (such as the support for copying private fields).

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

Sidebar

Related Questions

I'm in urgent need of an Objective-C/Cocoa/Cocoa Touch framework to handle simple charting; pie
Scrapy framework has the built-in capability to generate thumbnails. Is there any way to
I need to make a desktop app which is pretty complex and handles a
I want to be able to run the Scrapy web crawling framework from within
I have implemented a Domain Specific Language(DSL) using Xtext which contains expressions, so in
I'm developing a webapp with the flask framework as a backend and I need
I'm working on a framework extension which handles dynamic injection using Ninject as the
I am using Silverlight with a DDD approach. I have a Person domain object
I'm working on creating a domain layer in Zend Framework that is separate from
I'm looking for a python socket server framework - not to handle http, but

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.