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
38
votes
4 answers

MappedSuperclass - Change SequenceGenerator in Subclass

I'm using JPA2 with Hibernate and try to introduce a common base class for my entities. So far it looks like that: @MappedSuperclass public abstract class BaseEntity { @Id private Long id; @Override public int hashCode() { …
atamanroman
  • 11,607
  • 7
  • 57
  • 81
24
votes
2 answers

Hibernate : How override an attribute from mapped super class

The generic entity, super class: @MappedSuperclass public abstract class GenericEntity { private Integer id; public Integer getId() {return id;} public void setId(Integer id) {this.id = id;} } The pojo: @Entity @Table(name =…
BasicCoder
  • 1,661
  • 10
  • 27
  • 42
16
votes
1 answer

Can I use a generic Repository for all children of a MappedSuperClass with Spring Data JPA?

Given the following class structure: @MappedSuperclass @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public abstract class Animal {} @Entity public class Dog {} @Entity public class Cat {} With Spring Data JPA, is it possible to use a…
CFL_Jeff
  • 2,589
  • 3
  • 31
  • 49
12
votes
3 answers

Overriding @Id defined in a @MappedSuperclass with JPA

I have a class AbstractEntity that is extended by all the entities in my application and basically acts as an Identifier provider. @MappedSuperclass public class AbstractEntity implements DomainEntity { private static final long…
Sushant
  • 173
  • 1
  • 4
  • 15
11
votes
1 answer

Doctrine2 / Symfony2 - Multiple entities on same table

In a Symfony2 application I have a MainBundle and distinct bundles which can be enabled or not. In the MainBundle I need to have the Model and a basic Entity. In an OtherBundle an Entity with the same table name than Entity in MainBundle. Fixtures…
11
votes
3 answers

Doctrine2: OneToMany on mapped superclass

My DB structure is as follows: work: CTI table Work MappedSuperclass table AbstractImageWork which extends Work final table PhotoWork which extends AbstractImageWork comment: MappedSuperclass table Comment final table WorkComment which extends…
7
votes
1 answer

@MappedSuperclass and @OneToMany

I need association @OneToMany from Country to superclass Place (@MappedSuperclass). It could be bidirectional. I would need something like @OneToAny. @MappedSuperclass public class Place { private String name; private Country country; …
LancerX
  • 1,211
  • 7
  • 23
  • 40
7
votes
1 answer

Hibernate: how to fetch only not-logically deleted objects

Nearly every table in our database has a FK to the Auditing table which logs created, updated and deleted status (date and username). We mapped the auditing table to the Auditing class and use it like this: @MappedSuperclass public class…
joeriMJ
  • 103
  • 2
  • 6
7
votes
3 answers

EclipseLink @MappedSuperclass and generics

I have a few domain model classes in my web app that have a hierarchical relationship to themselves. An example of one is the hierarchical category structure used to classify users postings. There is some logic relating to the hierarchical nature of…
Tim P
  • 948
  • 1
  • 12
  • 19
6
votes
3 answers

Hibernate inheritance with different primary key

I'm trying to create a inheritance with TABLE_PER_CLASS strategy, but i want to have different primary key for each table is it possible? I've one class Register which has millions of instances, some of these instances are "special" and have…
Rafael Lima
  • 3,079
  • 3
  • 41
  • 105
6
votes
1 answer

symfony deployment error: mapped superclass

When I deploy a symfony website including mapped superclass entities online, I get the following error: AnnotationException: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\MappedSuperClass" in class Acme\DemoBundle\Entity\Foo does not…
Wisebes
  • 475
  • 4
  • 14
5
votes
2 answers

JPA MappedSuperclass with ManyToOne

I'm facing kind of typical issue. Imagine typical 1-N relationship between objects. To be precise User(U) and Room(R): [U]*---1[R]. Here comes the problem, Room should be abstract base class with implementations for example BlueRoom, RedRoom. How…
zdenda.online
  • 2,451
  • 3
  • 23
  • 45
5
votes
1 answer

Can I use @MappedSuperclass annotation on an interface?

I want to group common mappings in an interface, but I cannot use an abstract superclass because my entities already extend another class. So I need an interface like below: @MappedSuperclass public interface NamedEntity { @Column(name =…
Bahattin Ungormus
  • 628
  • 1
  • 9
  • 23
5
votes
1 answer

Symfony2 MappedSuperClass and doctrine:generate:entities

I have a "Offer" class (MapperSuperclass) and 2 more classes extending it, "PrivateOffer" and "PublicOffer". The problem I have is, when I run "doctrine:generate:entities" command, both classes "PrivateOffer" and "PublicOffer" are fullfilled with…
5
votes
1 answer

Value of 0 in Hibernate IndexColumn mapped with base=1

We are using Hibernate Annotations 3.4.0GA and Hibernate Core 3.3.2.GA (also known as the current stable versions) against an Oracle database We have a One-to-Many mapping with base=1 which worked fine for a loooong time, yet last week we found some…
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
1
2 3 4 5 6 7