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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:06:07+00:00 2026-06-15T04:06:07+00:00

I am using hibernate and in my data model I have I am using

  • 0

I am using hibernate and in my data model I have I am using Hibernate.Inheritence Single-Table in two different places but there is a problem when they react with eachother. Let me try to simplify with this example.

Basically what happens is when I do letter.setWord(word) then save it the word doesn’t have the reference back to the letter. From my understanding of mappedBy, you don’t have to explicitly set and save it on both ends do you? When I look in the database, the field is properly being set with the guid of the Word it is referencing. Am I doing something wrong?

Side Note: The reason I have the annotations on the getters is because hibernate won’t pick them up at all if they are put directly on the global variables. (I was getting no primary key errors set on the classes extending from Letter). Does hibernate just not handle multiple Inheritence Tables referencing eachother? When I only have one Inheritence table everything works fine with the annotations directly on the global variables.

Thanks,
Mike

@Entity
@Table(name="Letter")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name = "LETTER_TYPE",  
    discriminatorType=DiscriminatorType.STRING)
public abstract class Letter {

   private String id;

   private String value;

   private Word word;

   @Id
   @GeneratedValue(generator = "uuid")
   @GenericGenerator(name = "uuid", strategy = "org.hibernate.id.UUIDHexGenerator")
   @Access(AccessType.PROPERTY)
   public String getId() {
       return id;
   }

   @Column(name = "VALUE")
   @Access(AccessType.PROPERTY)
   public String getValue() {
         return value;
   }

   @ManyToOne
   @JoinColumn(name = "WORD_ID")
   @Access(AccessType.PROPERTY)
   public Word getWord() {
        return word;
   }

          ********BASIC SETTERS WITH NO ANNOTATIONS********
}

 @Entity
@Table(name="Word")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name = "WORD_TYPE",  
    discriminatorType=DiscriminatorType.STRING)
public abstract class Word {

   private String value;

   private List<Letter> letters;

   private String id;

   @Id
   @GeneratedValue(generator = "uuid")
   @GenericGenerator(name = "uuid", strategy = "org.hibernate.id.UUIDHexGenerator")
   @Access(AccessType.PROPERTY)
   public String getId() {
       return id;
   }

   @Column(name = "VALUE")
   @Access(AccessType.PROPERTY)
   public String getValue() {
         return value;
   }

  @OneToMany(mappedBy="word")
  @Cascade({CascadeType.ALL})
  @Access(AccessType.PROPERTY)
   public List<Letter> getLetters() {
        return letters;
   }

        ***************BASIC SETTERS WITH NO ANNOTATIONS**********
}
  • 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-15T04:06:08+00:00Added an answer on June 15, 2026 at 4:06 am

    Your understanding is mistaken, you are responsible for maintaining correct in memory state of the entities that you modify. Hibernate does not automatically go and add the new object to the in-memory entity on the other end.

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

Sidebar

Related Questions

I have build my data model using JPA and am using Hibernate's EntityManager 3
I have a JPA/Hibernate data model that I am using the Hibernate hbm2ddl tool
I am trying to design an entity model using JPA2.0 via hibernate. I have
I have a simple data model in JPA (hibernate) consisting of many to one
I'm using (fluent) nhibernate and I've run into a little problem. My data model
We are using Hibernate as persistency layer and have complex object model. Without exposing
I have problem using Fluent Nhibernate, I have following model. When I try to
I have a problem with hashCode() that delegates to uninitialized objects using hibernate. My
When using hibernate to retrieve data from Oracle 11g DB using either org.hibernate.dialect.Oracle10gDialect or
I am using Hibernate 3.0. Following is the criteria written for fetching data. 1.

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.