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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:23:11+00:00 2026-06-13T20:23:11+00:00

I have the following problem: I have a base class (used as superclass) with

  • 0

I have the following problem:

I have a base class (used as superclass) with a composite primary key. And now I’am trying to setup subclasses correctly from the base class, but this doesn’t work! Could somebody help me? Thanks

Here are my classes:

BasePK.java

@Embeddable
public class BasePK implements Serializeable {
  protected String base1;
  protected Timestamp base2;
  ..
}

Base.java

@MappedSuperclass
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class Base implements Serializeable {
  @EmbeddedId
  protected BasePK id;
  ..
}

SubClassA.java

@Entity
public class SubClassA extends Base implements Serializeable {

  @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="attrA")
  protected List<SubClassB> attrsB;

  protected String attrA1;
  protected String attrA2;
  ..
}

SubClassB.java

@Entity
public class SubClassB extends Base implements Serializeable {

  @ManyToOne(fetch=FetchType.LAZY)
  private SubClassA attrA;

  protected String attrB1;
  protected String attrB2;
  ..
}

SubClassC.java

@Entity
public class SubClassC extends SubClassA implements Serializeable {


  protected String attrC1;
  protected String attrC2;
  ..
}

When I try to run the project, the following excetions are made:

[EL Info]: 2012-11-01 23:31:18.739--ServerSession(2063330336)--EclipseLink, version: Eclipse Persistence Services - 2.4.1.v20121003-ad44345
[EL Warning]: metadata: 2012-11-01 23:31:19.199--ServerSession(2063330336)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [controlledObject] for the entity class [class logyourlife.entities.ChangeRecord] since weaving was not enabled or did not occur.
[EL Severe]: 2012-11-01 23:31:19.229--ServerSession(2063330336)--Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-48] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field [SUBCLASSB.BASE1].  Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.ManyToOneMapping[attrA]
Descriptor: RelationalDescriptor(test.entities.SubClassB --> [DatabaseTable(SUBCLASSB)])

Exception [EclipseLink-48] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field [SUBCLASSB.BASE2].  Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.ManyToOneMapping[attrA]
Descriptor: RelationalDescriptor(test.entities.SubClassB --> [DatabaseTable(SUBCLASSB)])

fyi: The equals and hashcode method are overwritten in all classes.

  • 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-13T20:23:12+00:00Added an answer on June 13, 2026 at 8:23 pm

    First of all, remove the @Inheritance annotation on Base. It doesn’t serve any purpose.

    Then, try to explicitely define join columns for the ManyToOne association. It seems EclipseLink uses the same column names by default both for the embedded ID fields and for the many-to-one association with SubClassA. See http://docs.oracle.com/javaee/6/api/javax/persistence/JoinColumn.html for an example of using this annotation.

    Side note: composite IDs are both inefficient, and complex to handle. You should really consider using autogenerated, single-column IDs for all your entities. Everything would be much easier.

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

Sidebar

Related Questions

I have the following problem with inheritance and templates: class Base {}; class Deriv
Consider the following problem: You have a class 'A' that serves as a base
I'm learning C# and I encountered the following problem. I have two classes: base
I am little bit stuck with the following problem. I have two models: class
I have the following problem at hand. There is a class, Foo and another
I have the following problem: class A { void f() {} } class B
I need help with the following problem: I have a class with two properties.
I have a class similar to the following: class FruitKinds < ActiveRecord::Base Apple =
I have following problem: I have to make a ASP.NET Webapplication with a two-row
I have following problem: I have built a tabbar application with 4 tabs. I

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.