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

  • Home
  • SEARCH
  • 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 7618105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:18:53+00:00 2026-05-31T03:18:53+00:00

I have class @Embeddable public class MyClass implements Serializable { private String field1; private

  • 0

I have class

@Embeddable
public class MyClass implements Serializable
{
   private String field1;
   private String field2;
   private String field3;

// getters, setters
}

and I have mapped class

public class MappedClass implements Serializable
{
   @Embedded
   @AttributeOverrides(
      {
        @AttributeOverride(name = "field1", column = @Column(name = "column1")),
        @AttributeOverride(name = "field2", column = @Column(name = "column2")),
        @AttributeOverride(name = "field3", column = @Column(name = "column3"))
      })
   private MyClass myClassField1;

   @Embedded
   @AttributeOverrides(
      {
        @AttributeOverride(name = "field1", column = @Column(name = "column1")),
        @AttributeOverride(name = "field2", column = @Column(name = "column2")),
      })
   private MyClass myClassField2;

// setters, getters

}

I want that ‘filed3’ in myClassField2 be ‘null’, becouse ‘field3’ hasn’t DB mapping.
What can I do? JPA search value for ‘field3’ in column ‘field3’

In Hibernate all passed normal!

   <component name="myClassField1" class="MappedClass">
           <property name="field1" type="string" column="column1" />
           <property name="field2" type="string" column="column2" />
           <property name="field3" type="string" column="column3" />
   <component/>  

   <component name="myClassField2" class="MappedClass">
           <property name="field1" type="string" column="column1" />
           <property name="field2" type="string" column="column2" />
   <component/>  

But I need this in JPA

  • 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-31T03:18:54+00:00Added an answer on May 31, 2026 at 3:18 am

    What you want to do is impossible. EIther a field is persistent, or it’s transient. It can’t be sometimes one and sometimes the other.

    Consider defining a MyClass1 with just two fields, and a MyClass2 extending MyClass1 and adding the third field. Use the first one for myClassField2, and the second one for myClassField1.

    Note that, in your example, you have mapped column1 and column2 twice, which is also incorrect.

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

Sidebar

Related Questions

I have: class MyClass extends MyClass2 implements Serializable { //... } In MyClass2 is
I have class which implements Countable, ArrayAccess, Iterator and Serializable. I have a public
I have class: public class EnglishWord implements Serializable, Comparable, Cloneable { static Logger logger
I have: class first{ private: int *array; public: first(int x){ array = new int[x][10];
I am using an embedded id: @Embeddable public class EntityId { private long id;
@Entity public class Person { @ElementCollection private List<Location> locations; [...] } @Embeddable public class
I have class A: public class ClassA<T> Class B derives from A: public class
I have class A: public B { ...} vector<A*> v; I want to do
I have class Fred { public: void inspect() const {}; void modify(){}; }; int
I have problems creating a custom query. This is what entities: @Entity public class

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.