Questions tagged [mappedsuperclass]

Annotation for a class that entity classes inherit from

Annotation for a class that entity classes inherit from. The mapped super class is annotated with a specific @annotation and does not exist in the database as a table. Typically, the purpose of such a mapped super class is to define state and mapping information that is common to multiple entity classes.

The concept of mapped super classes is for example used in:

105 questions
4
votes
1 answer

Hibernate TABLE_PER_CLASS with @MappedSuperclass won't create UNION query

I am trying to create a series of objects that all are stored in separate tables, but that there is a set of fields in common on all these tables. I want Hibernate to do a UNION of all these tables, but NOT INCLUDE the superclass as a table. When I…
4
votes
4 answers

Applying annotations to fields inherited from @MappedSuperclass

Has: @MappedSuperclass class Superclass { @Id @Column(name = "id") protected long id; @Column(name="field") private long field; } and @Entity class Subclass extends Superclass { } How to annotate inherited id with…
Timofey Gorshkov
  • 4,987
  • 6
  • 41
  • 66
4
votes
1 answer

Doctrine MappedSuperClass, override custom annotation

I am wondering if there is a way to change (or define inside) annotations in a child class inheriting a MappedSuperClass, for example, let say we have a class BaseUser (mappedsuperclass), a child class User :
Bil5
  • 502
  • 1
  • 5
  • 15
4
votes
1 answer

Symfony2 MongoDB Doctrine Inheritance

I come with a little problem that I tried to understand in vain... I have 2 classes. One is an abstract Document called "SpecificIndividual" and the other one is a regular Document called "Individual". This is what I want to do : SpecificIndividual…
4
votes
2 answers

why same Id on @MappedSuperclass when @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)

I try to have 2 tables, as follows: MISExercise (table) ID NAME ... 2 a MISInteractiveExercise(table) ID NAME ... 1 b They must have no same id. And they are inherited from the same base. My code is : @MappedSuperclass …
toxin
  • 93
  • 1
  • 6
4
votes
1 answer

JPA @MappedSuperclass in separate JAR in Eclipse causes validation error "The entity has no primary key attribute defined"

I've got a @MappedSuperclass AbstractEntity that I use for all of my @Entity classes. It works perfectly as long as the superclass is in the same Eclipse project as my entities. But since I reuse this superclass among several projects, I just want…
RyanC
  • 131
  • 1
  • 4
3
votes
0 answers

How to best model inheritance in JPA entities

I'm wondering what the best practice is to use inheritance in JPA entities if the entities don't share a primary key, in particular if the database already exists and cannot easily be changed. Assume we have an employee database, like the one used…
jmartin
  • 41
  • 4
3
votes
1 answer

Hibernate proxy object not working for superclass methods

We have a web application that uses Hibernate. After upgrading the codebase to Hibernate 3.6 (from 3.3.2) I've found that the proxy data objects generated by Hibernate only return the correct value for some methods. It seems that methods in a…
gutch
  • 6,959
  • 3
  • 36
  • 53
3
votes
1 answer

JPA/Hibernate @MappedSuperclass and @Inheritance(strategy = InheritanceType.JOINED) relation

I have 3 tables represented by JPA model. The first one: @MappedSuperclass public abstract class BaseEntity { @Id private Long id; private Boolean active; } Next class extends BaseEntity: @Entity @Inheritance(strategy =…
Yuriy Gorbylov
  • 104
  • 1
  • 5
3
votes
2 answers

JPA @MappedSuperclass different Id counters for subclasses

I've got a @MappedSuperclass which is my base-class for all my entities (@Entity, direct or indirect through multiple sub-classing). @Id @GeneratedValue(strategy = GenerationType.AUTO) @XmlAttribute(required = true) private Long primaryKey; The Id…
user1199624
3
votes
2 answers

Silex + Doctrine ORM doesn't fire events when set on @MappedSuperclass

I am using Silex with Doctrine ORM, everything was working properly but I got a problem that I can't figure out. I have an Entity News in the namespace Lpdq\Model\Entity which extends another class News in the namespace Lpdq\Model which contains…
joubjoub
  • 31
  • 3
3
votes
1 answer

How to create composite key using spring-jpa where one attribute of the key is in @MappedSuperClass and other attribute is in @Entity class?

I need to create a composite key. One attribute of the key is in a MappedSuperClass which I cannot modify. The other attribute of the key is in the derived class which is an entity class. However, I get a runtime error on executing the below which…
3
votes
1 answer

Entity listener on a @MappedSuperclass does not work?

Background I am using EclipseLink (version 2.3.2.v20111125-r10461, implementation provider for the JPA 2.0 specification). Consider this @MappedSuperclass, called Person: @MappedSuperclass @EntityListeners({Listener.class}) public abstract class…
3
votes
1 answer

How to override parameter in sublass of @MappedSuperclass

I have a MappedSuperclass @MappedSuperclass public class A{ . . . @Column(name="something") public getSomething(){..}; public setSomething(){..}; } I want to override the something in a subclass @Entity public class B{ …
adsurbum
  • 3,107
  • 3
  • 22
  • 27
2
votes
1 answer

Symfony: include MappedSuperClass form inside another Form Type

in Symfony 6, I have a MappedSuperclass Entity called Person with personal data (name, surnames, etc.). #[ORM\MappedSuperclass] class Person { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; …
K. Weber
  • 2,643
  • 5
  • 45
  • 77