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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:34:39+00:00 2026-06-12T18:34:39+00:00

I have a Hibernate @Embeddable annotated class like so @Embeddable public class DataWrapper {

  • 0

I have a Hibernate @Embeddable annotated class like so

@Embeddable
public class DataWrapper {
    private DataWrapperType wrapperType;

    @ManyToOne
    private DataFactorX xFactor;
    @ManyToOne
    private DataFactorY yFactor;
    @ManyToOne
    private DataFactorZ zFactor;

    // Getters and Setters
}

and it’s pretty simply used in another entity

@Entity
public class DataManager {
    private DataWrapper dataWrapper;

    public DataManager() {
        this.dataWrapper = new DataWrapper();
    }
}

but when I later retrieve a DataManager instance from Hibernate, the dataWrapper field comes back null.

Any explanation?

  • 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-12T18:34:40+00:00Added an answer on June 12, 2026 at 6:34 pm

    I have the answer now, but I went ahead and posted because it was not obvious to me as a Hibernate amateur. Based on this answer by ChssPly76, I now see that Hibernate will set a component to null when all of it’s fields are null. This behavior is official and documented I found out here:

    The null value semantics of a component are ad hoc. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This is suitable for most purposes.

    This means that while you’re still working with the reference that you set the field on, it will stay set, but if you query Hibernate to retrieve this object again, that field will be null if all of its components are null.

    Hope that helps someone else not chase NullPointerExceptions through otherwise working Java code.

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

Sidebar

Related Questions

I have class @Embeddable public class MyClass implements Serializable { private String field1; private
I have a Hibernate mapping that looks something like this: <class name=MyEntity> <set name=scalarSet
I have a DateInterval class that is annotated with @Embeddable and it has two
@Embeddable @MappedSuperclass public class Address { private String street; private String city; public String
I have Hibernate Objects defined as Class SomeText{ private Long textId; private Set<Tag> Tags
I have a class that I am creating a Hibernate mapping which contains a
I have Hibernate Transaction manager configured inside Spring MVC controller. <bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource destroy-method=close>
I have hibernate @Entity called Video with fields: @Column(name=TC_IN) private BigDecimal tcIn; @Column(name=TC_OUT) private
I have a problem with my hibernate mapping using EmbeddedId. My code looks like
I have Hibernate Entities that look something like this (getters and setters left out):

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.