strategy « Map « JPA Q&A





1. Hibernate Inheritance Strategy and Why    stackoverflow.com

I have 3 non-abstract persist-able classes. MyClubUser and HisClubUser classes inherit from User class. I use one table per subclass strategy i.e. @Inheritance(strategy = InheritanceType.JOINED), for these classes. What I have ...

2. Changing the inheritance strategy in branches of the class hierarchy via JPA annotations    stackoverflow.com

Today I faced an interesting issue. I've been having an inheritance hierarchy with Hibernate JPA, with SINGLE_TABLE strategy. Later, I added a superclass to the hierarchy, which defined TABLE_PER_CLASS strategy. The ...

3. Why EclipseLink is adding discriminator column for joined inheritance strategy?    stackoverflow.com

I am using JOINED inheritance strategy with EclipseLink JPA implementation. I have noticed that EclipseLink is adding discriminator column, named by default DTYPE, to the database schema. I understand, that discriminator ...

4. What is a good inheritance strategy with Hibernate and JPA?    stackoverflow.com

i have this situation: I have an entity, "Person", that contains all personal details of a person, like birth date, street address, municipality ecc ecc. And i have an entity "ClubMember" that describe ...

5. SINGLE_TABLE inheritance strategy using enums as discriminator value    stackoverflow.com

Is it possible to use an enum as a discriminator value when using SINGLE_TABLE inheritance strategy?

6. hibernate fetch strategy when using one table per class hierarchy inheritance    stackoverflow.com

Hello I am using the one table per class hierarchy inheritance mapping to legacy data as described here http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritance.html#inheritance-tableperclass here is what my mapping roughly looks like

<class abstract="true" name="note" table="NOTES">
 <id name="id" ...

7. JVM crashing when using any other Hibernate inheritance strategy besides SINGLE_TABLE    stackoverflow.com

Ok, this is probably a longshot but here goes. In Java (JRE 1.6.0_26-b03) I have two classes, SuperControl and its subclass SubControl. They both need to be persistent objects and I'm using ...

8. JPA Mixed Inheritance Strategy    stackoverflow.com

I have 3 entities:

@Entity
public abstract class A {
  @Id
  public Long id;
  public String a1;
  public String a2;
  public String a3;

  //much more ...

9. Mock JOINED inheritance strategy without actual inheritance    stackoverflow.com

I want to use mixed @Inheritance strategy, but Hibernate doesn't support it.
Is there any way to implement JOINED inheritance without actual class inheritance. For example:

@Entity
@Table(name="A")
@Inheritance(strategy=InheritanceType.JOINED)
public class A { 
  @Id
  ...





10. Is there a way to override inherited generation strategy?    stackoverflow.com

I'm extending an entity which doesn't auto generate its id. I want to 'override' its generation strategy to AUTO in my derived class. Something like this.

@Entity
public class Base {

    @Id
 ...

11. Switching Inheritance Strategy from JOINED to SINGLE TABLE    stackoverflow.com

Ive made a stupid error in a production system. I chose JOINED strategy instead of SINGLE TABLE, and performance is seriously taking a hit. I need to switch stragies and make appropriate changes ...

12. Hibernate Mapping Strategy    coderanch.com

I'm having trouble figuring out how to logically create the following entity association. I have 2 entities. A User and an Event. 1) Each event needs to have a set of users. 2) Each user needs to have a set of users. 3) Each of the user sets per user need to relate to a unique event. I know how to ...

13. Hibernate Inheritance Strategy and Why    coderanch.com

Hi, I have 3 non-abstract persist-able classes. MyClubUser and HisClubUser classes inherit from User class. I use one table per subclass strategy i.e. @Inheritance(strategy = InheritanceType.JOINED), for these classes. What I have observed was the generated SQL uses left outer join HisClubUser and MyClubUser when I do a query on User class. Why Hibernate does that [joining other tables] where my ...

14. which inheritance strategy is best for this situation    forum.hibernate.org

I have 3 tables which are arranged like this. Parent has 2 columns ID and Type. Type is a string which determines the child. Child1 has 3 columns ID, c11 and c12. ID is linked to ID of Parent as a foreign key. Child2 has 3 columns ID, c21 and c22. ID is linked to ID of Parent as a foreign ...

15. RESOLVED: Inheritance.JOINED strategy and Generated Id    forum.hibernate.org

@MappedSuperclass public abstract class AbstractHistorizedEntity implements Serializable { protected Long id; ... @Id @Column(name = "id", unique = true, nullable = false) public Long getId() { return id; } ... }

16. Optimal mapping strategy for multiple one-to-many    forum.hibernate.org

I'd like to get people's opinion on the optimal way to map the following: I have an entity "App" and an entity "Group". A group belongs to an app (that is, it's a many groups to one app relationship). An app can have many groups. An app can also have a list of default groups. So the App entity has two ...





17. Inheritance Join Strategy and DiscriminatorColumn    forum.hibernate.org

Hi, We are using JPA annotations in a standard seam application. I have seen this jira http://opensource.atlassian.com/projects/hibernate/browse/ANN-140 and was wondering whether this is still how things stand. Is is not possible to use a DiscriminatorColumn when using the join inheritance strategy? I understand that it is not required but in our case we have hundreds of classes extending a particular class. ...

18. Multiple inheritance and mixed strategy    forum.hibernate.org

19. Inheritance strategy without discriminator (for read/write)    forum.hibernate.org

Hi, Im wondering if it's possible to configure subclasses without any discriminator? When you use SINGLE_CLASS inheritance strategy you must specify a discriminator column/value. By default is will populate the column as DTYPE which results in the following error: ORA-00904: "DTYPE": invalid identifier I have an entity which extends from another base entity. The parent entity has all the persistence annotations. ...

20. Inheritance strategy 'joined' + discriminator field 'type'?    forum.hibernate.org

Hello, I've got a pretty basic question. Let's say I have a class hierarchy A <- B (class B extends class A). Both are beans and saved by hibernate into the database. To map the hierarchy, I know two methods so far: 1. all in same table: A and B will be saved in one table, and the field "type" will ...

21. Switching Inheritance Strategy from JOINED to SINGLE TABLE    forum.hibernate.org

Hi All Ive made a stupid error in a production system. I chose JOINED strategy instead of SINGLE TABLE, and performance is seriously taking a hit. I need to switch stragies and make appropriate changes to the schema, cant believe i screwed this up. I would really appreciate and need some advice on how best to proceed. Hibernate 3.5.6, JPA 2.0, ...

22. Strategy for Mapping Lookup tables    forum.hibernate.org

Hello, I am trying to map a lookup table (a table with three columns, each a FK to other tables) to a Test class using Hibernate. The columns are: TestTypeID TestCategoryID QuestionID There can be multiple QuestionID entries for identical combinations of TestTypeID and TestCategoryID. There will be a unique combination of all three in the record at one time. I ...

23. Which map strategy for 2 classes over 1 table    forum.hibernate.org

I whould like to have some suggestions about this situation: There is a large table, with 60 columns (TABLE_A). The first 20 columns are always used, while the others are used seldom. I would like to have 2 classes (LightClass & HeavyClass) to not transfer to client-side all the 60 columns (using LightClass with only the first 20 columns). Which is ...

24. Lookup table mapping strategy    forum.hibernate.org

In our application, we have few lookup tables. They store static data and not changeable. What is the strategy to implement mapping? I use UserType which works fine. But it seems decoupling the database table and Java class. For example, if I have a table stores all addres types such as home address, mailing address ..., in my Typesave emnu class, ...

25. Seeking mapping strategy suggestions    forum.hibernate.org

26. best mapping strategy for images    forum.hibernate.org

Hibernate version:2.16 mysql and hibernate: Hi there, I'm just in a little bit of confusion recently regarding the best way to store image files to the database. I am reading that blob and clob are not necessary portable to all databases. I'm really concentrating on mysql and postgres for the first version of my project. What is the best strategy to ...

27. many to many mapping strategy    forum.hibernate.org

28. Mapping strategy:simple association 1class 4 muiltipl tables    forum.hibernate.org

I have two tables Table 1 -> JOB (job_uid,jobname,assigned_user_id,modifyon,modifyby) Table 2 : JOB_SAMPLE (jobsample_uid,job_uid,sample_uid) Where sample is another persistent class. I was trying to do a Single class for these two tables. Q1. Is it a good practice to map a single class to muiltiple tables? Q2. If not any alternate suggestions would be helpful. Pardon me if its sounds trivial ...

29. Recommended interface inheritance strategy?    forum.hibernate.org

I've been toying with many differnet inheritence strategies today, and I was hoping someone could point me to the Right Way to set it up. I want a way to flag some classes as having a Calendar. It made sense to use an interface, so I called that Schedulable. Now suppose I have Resource, User, and Room that all need a ...

30. 1:1 association and cascade strategy for child    forum.hibernate.org

Hello All, I am trying to write a remove operation for a child object from an association. The association is on 1:0_1 type, Request being the owner and Agreement the child. Please refer to the mappings below. Since it is mandatory for an Agreement to have a Request reference present, removal of Agreement from an association should cause the Agreement record ...

31. Best mapping strategy    forum.hibernate.org

Hi all together, I have the following situation: Many different entities (Customer, Supplier, Product etc.) and I want to map different instances to some kind of access role, where AccessRole must be always the same entity type and one specific instance (Customer 1) belongs to one specific instance of AccessRole. AccessRole itself should hold a list of AccessRight and one AccessRight ...

32. Overriding mapping file fetch strategy    forum.hibernate.org

Is is possible to override the hbm.xml fetch strategy. I have one to many mappings which are set to lazy = "false". Is it possible to write a query so that the association is NOT initialized (as if you had set lazy = "true") in the mapping. My initial instinct was that it would be possible to use the Criteria API ...

33. Overriding mapping fetch strategy using criteria    forum.hibernate.org

Hi, Does anyone know how to enable the join fetch strategy in objects that are collections deeper in the tree hierarchy ? Example: You have a root object A with two references to B and C. B has a collection D and C has a collection E. Reading the docs this should be as simple as: // Criteria for the root ...

34. Mapping Strategy for Existing DB/tables having the same keys    forum.hibernate.org

I'd like to know how it is best to use hibernate in existing database with table with most keys are the same. i think most of the tables relates using these keys only with no foreign key constraints. table1 sId rId mId ... table2 sId rId mId .... any help is greatly appreciated. thanks alexa

35. question on table-per-class-hierarchy mapping strategy    forum.hibernate.org

I am using the table-per-class-hierarchy mapping strategy to persist an entire class hierarchy into a singe table. I understand I can map a single subclass in this hierarchy to a separate table using the mapping element. Is there a way, however, to persist an entire branch or subtree of this class hierarchy rooted at a given subclass to a seperate ...

36. Mapping strategy for custom assigned IDs    forum.hibernate.org

Hi, I am experiencing some problems with a Structure that looks like the following: Article has Set has Set I am assigning the IDs myself, they're strings. However, I try to saveOrUpdate the final article and cascade the Topics and Items down. There is however one problem - some topics might include the same items - that's when I get the ...

37. problem referring to child entity with SINGLE_TABLE strategy    forum.hibernate.org

Hibernate version: 3.2.1.ga I have the following entities: @Entity @Table(name="CS_CODIF") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="CODIF_GROUP", discriminatorType=DiscriminatorType.STRING) public abstract class Codif { @Id @GeneratedValue @Column(name = "ID") private Long id; @Column(name="CODE", nullable=false) private String code; @Column(name="LABEL", nullable=false) private String label; } @Entity @DiscriminatorValue("SECTOR_A") public class SectorA extends Codif { } @Entity @DiscriminatorValue("SECTOR_B") public class SectorB extends Codif { } @Entity @Table(name = "CS_INSTRUMENT") public class ...

38. complicated inheritance strategy mapping    forum.hibernate.org

public class A { // mapped to table TB_A with a discriminator ... } public class B extends A { // mapped to table TB_B ... } public abstract class C extends B { // mapped to table TB_C ... } public class D extends C { // mapped to table TB_C ... } public class E extends C { // ...

39. Mix Inheritance Strategy in hierarchy... is this possible?    forum.hibernate.org

I am trying the following hierarchy and I can get it to work when I run select's however, when I try to insert data, it fails with a Contraint Violation Exception. If I add a BaseContactVO it persists fine, but if I create a new ContactVO then it seems to want to add it twice to the same table and thus ...

40. Mapping Strategy    forum.hibernate.org

I cant wrap my brain around this one.. didnt eat breakfast might be the cause. I want to create a messaging system between users. 2 users are related to 1 message each user can have many message how do i map this relationship? is it 1) a user entity has a many to one relationship with a message entity 2) a ...

41. Single Table Strategy Inheritance Question    forum.hibernate.org

42. best strategy for inheritance    forum.hibernate.org

hi there, we are after a little advice if possible. we are trying to build a generic, extensible, community-ish framework, and part of that is the desire to make certain elements commentable - ie people can leave comments on pictures, images, forum posts, etc etc. however, as it is a framework, we will need to extend this functionality to make the ...

43. Stuck with propper inheritance strategy choice    forum.hibernate.org

Hi. I'd like to ask the experienced hibernate users for advice to choose a correct inheritance subclassing strategy. I've read the online documentation as well as (very useful, btw) java persistence with hibernate book, and still stuck... Here is the deal: I have a table hierarchy for multilingual support, that consists of one main table and multipple language tables for each ...

44. Stuck with propper inheritance strategy choice    forum.hibernate.org

Hi. I'd like to ask the experienced hibernate users for advice to choose a correct inheritance subclassing strategy. I've read the online documentation as well as (very useful, btw) java persistence with hibernate book, and still stuck... Here is the deal: I have a table hierarchy for multilingual support, that consists of one main table and multipple language tables for each ...