hierarchy « Map « JPA Q&A





1. Hibernate Table per Hierarchy How to    stackoverflow.com

I would like to use hibernate to contain a hierarchy of objects, however the discriminator column is a foreign key to another table that contains the CODE defining the subclass type. ...

2. Hibernate parent-child modeling    stackoverflow.com

I have a Model class. This class should be able to reference itself, i.e. the resulting "output" from the model should be like this.

Some instanceOf Model.class
|-> Some instanceOf Model.class having parent ...

3. How to mix inheritance strategies with JPA annotations and Hibernate?    stackoverflow.com

According to the Hibernate Reference Documentation it should be possible to mix different inheritance mapping strategies when using Hibernate's XML-Metadata:
http://docs.jboss.org/hibernate/stable/core/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass However, the corresponding section of the Hibernate Annotations Reference Guide ...

4. JPA: is it possible to change the PKs in an inheritance hierarchy?    stackoverflow.com

I have the following DB design: Valid XHTML As you can see States, Countries, and Continents are all sub tables of GeoAreas. The interesting fact here is that States and Countries ...

5. Mapping a class hierarchy to multiple tables    forum.hibernate.org

Hello, I ran into a problem with Hibernate 3.3.2 GA regarding the mapping of a class hierarchy to multiple tables. This is what I want to do: I have one class "employee" and a derived class "manager". This simple class hierarchy shall be mapped to the table "t_employee" with the following mapping: Code: ...

6. Querying from Inheritance Hierarchy    forum.hibernate.org

Hi, Suppose I have inheritance hierarchy SuperClass is Payment, Subclass is CreditPayment,CashPayment. And I query from hql "from Payment p". It will fetch the records from Payment, CreditPayment and CashPayment. But I want records from only Payments and not from it's subclasses. How to do that. I tried explicit polymorphism. But not working. Suppose Payment has 1 record, CreditPayment has 2 ...

7. Mapping of inheritance hierarchy    forum.hibernate.org

I have experimented with the mapping of inheritance hierarchies in Hibernate. Below are my findings, can someone please tell me if they are correct? 1. Hibernate allows only either table-per-class-hierarchy (i.e. ) mapping or table-per-subclass mapping (i.e. ) but no mixture. 2. Hibernate does not support switching between the two modes further down in the class hierarchy. 3. Hibernate does not ...

8. table-per-class-hierarchy mapping recommended. Why?    forum.hibernate.org

I ask because I currently use that strategy when modeling inheritance, but now my company's database people would prefer that I switch to the table-per-subclass mapping strategy (joined-sublcass). Section 16.2 of the hibernate reference assures me that I'll still get all the polymorphic behavior I want with table-per-subclass, but I figure table-per-class-hierarchy is recommended because of performance issues. And I'd hate ...

9. Many to Many Mapping with Table per class hierarchy.    forum.hibernate.org

I have a case where I have one table that uses the Table per class hierarchy (Content, with ContentType1 and ContentType2 as subclasses), and another normal table (Category). These classes have a many to many relationship using a third mapping table. The basic relationship works, but I have had problems in a couple of cases. I first noticed the problem when ...





10. Adding new classes to existing inheritance hierarchy    forum.hibernate.org

Hi, We have an application that is split into the 'core' part and separate 'module' parts. The 'core' part defines (and persists) some base classes that are extended and also persisted by specific 'modules'. What we're looking to achieve in the future is to be able to easily deploy additional modules: stop the server, drop in a new jar(s), start the ...

11. table-per-hierarchy 1:1 mapping doesn't use discriminator??    forum.hibernate.org

Hello, I have a class (ProblemSolvingEntry) with one-to-one mappings to three other classes (ReframingEntry, CommunicatingEntry, DoingEntry). Each of the three classes have keys pointing back to ProblemSolvingEntry. All four of the classes are subclasses of the same superclass (notebook.Entry) and are stored in the same table (implementing the "table per class hierarchy" design). The three subclasses all use the same column ...

12. Mapping of hierarchy and order of elements    forum.hibernate.org

Hi all, thank you for your interesting answers yesterday. I reconsidered my car example and created real instances from the following XML-file (Car, Tyre, Seat ..) One Two Three Four ... ... ... ... Given the existing db-schemas TABLE CarHierarchy ( ...

13. Mapping an interface hierarchy with more than a root    forum.hibernate.org

I have the following: Code: Contactable Accountable (interfaces) ^ ^ | | Party (interfaces) ...

14. Table per class hierarchy mapping doubts    forum.hibernate.org

15. mapping a category hierarchy in hibernate    forum.hibernate.org

hi, i have a legacy application that stores a category hierarchy using two tables: CATEGORIES: - CATEGORY_ID (PK) - CATNAME - TYPE_ID CATEGORY_HIERARCHY: - PARENT_CATEGORY_ID - CHILD_CATEGORY_ID it's ugly; multiple parentage is allowed and there's no PK on the category_hierarchy table. the main reason it was designed in this way was to support oracle's "connect by prior" mechanism for hierarchical data. ...

16. mapping a tree hierarchy -> root, node, leaf    forum.hibernate.org





17. Exception thrown if interface hierarchy defined in mapping.    forum.hibernate.org

Hibernate 3.0.3 I have created a mapping file that contains a hierarchy of abstract and concrete subclasses and a parallel hierarchy of interfaces (for use as proxies). I saw nothing in particular in the documentation that discouraged this. An example mapping: true ...

18. Mapping non-isomorphic interface and class hierarchy    forum.hibernate.org

I wish to map an interface hierarchy which is implemented by a set of classes which do not have similar hierarchy. Example: Mapped classes: Code: public interface IParent { int getP(); void setP(int p); } public interface IChild extends IParent { int getC(); void setC(int ...

19. Deep inheritance hierarchy    forum.hibernate.org

Folk, I have a deep inheritance hierarchy I am trying to map to Hibernate. There are about 180 classes in the set. All classes are commonly rooted in a single class, Top. Top has numerous associations bound to it so that all objects have the option of participating in those associations. The problem I face is how to resolve the abstract ...

20. Unmapped class in inheritance hierarchy    forum.hibernate.org

Newbie Joined: Fri Feb 25, 2005 3:40 pm Posts: 8 Location: Victoria, BC Canada I have the following class structure: A is abstract and mapped. B inherits from A and is abstract, but has no map. C inherits from A and is concrete and mapped as joined-sublass. D inherits from B and is concrete and mapped as joined-sublass. E inherits from ...

21. How to map *value object* hierarchy?    forum.hibernate.org

22. Why Hibernate can't map *value object* hierarchy?    forum.hibernate.org

Hi all. Beside all the goodies that Hibernate has for mapping domain model, is there some special reason why it cannot map hierarchy of value objects, only entities? There is whole chapter about mapping hierarchy of entities and various strategies for it, but no mention about value objects like they cannot have hierarchy. I can only map plain value object using ...

23. table per class hierarchy mapping    forum.hibernate.org

hi, i am new to hibernate. i have a query. i have the following class heirarchy Interface A Class B implements A Class C extends B Class D extends B Class E extends B Class F extends C What will be the mapping for this if i were to use table per class hierarchy Thanks in advance

24. Mapping this hierarchy doable?    forum.hibernate.org

Hibernate version:3.1 Mapping documents: my question I've picked up Hibernate 3.1 after a long layoff. There has been much improvement since 2.x. I would like to know if the following is doable. I've read throught the manual and it is not clear to me if it is. Class Hierarchy is: Code: ...

25. Mapping of Two Class Hierarchies with an Association    forum.hibernate.org

Newbie Joined: Tue Mar 28, 2006 7:49 am Posts: 8 Hi, I'm new to Hibernate (which I'm enjoying -- honestly!) and have a question regarding an association between two class hierarchys, which are mapped to a table-per-class hierarchy strategy. (see bad uml below for class association :-) Code: ______________ ...

26. many-to-one/one-to-many mappings with table per hierarchy    forum.hibernate.org

I am trying to create a class containing a set of any of a number of subclasses which are stored in a single table, using the descriminator column to differentiate the subclasses. i.e.: Code: public class A{ private long id; private Set setofB; . . . public Set getSetofB(){ ...

27. inheritance with per class hierarchy    forum.hibernate.org

Hi, I was wondering how to do a simple per-class-hierarchy mapping for an object graph 3 levels deep. For example, say I want to map the abstract base classes X <-- Y <-- Z. I assumed you can nest the element in order to achieve this but I'm not getting the result I want when hibernate generates the schema. Here ...

28. Advice on mapping hierarchy    forum.hibernate.org

Our system has a fairly deep (5 class) and wide (total of 8 classes) hierarchy that we are trying to map to our database. Our model (at least this part) looks something like this: Code: ...

29. Help with hierarchy mapping needed    forum.hibernate.org

I am working off an existing schema with discriminator. I have the following hierarchy: concrete class with table, abstract class with a couple of attributes (no table) and multiple subclasses each with their own table where the attributes of the abstract class are mapped and the primary key points to the primary key of the first concrete class. In a 'picture' ...

30. help with hierarchy mapping?    forum.hibernate.org

31. problem with "single table per inheritance hierarchy&qu    forum.hibernate.org

Hi, I am using the inheritance strategy "single table per class hierarchy" to implement the directory structure of a file system (see example below). Everything works fine except the fetching of the collections: when fetching the subdirectories with dir.getSubdirs(), I also get the files; further, when fetching the files with dir.getFiles() I get an exception because contained subdirectories are also fetched. ...

32. per-hierarchy mapping causes queries to not return vals.    forum.hibernate.org

if I try and use spring's load (instead of find[=query]) on the instances of the subclass, it works fine - meaning I can call load(SubscriberValue.class, "123"), and I get the instance. but if I try the query "From com.pontis.app.subscriber.SubscriberValue where refcode="123", the results are null and the SQL contains where 1=2. Assaf.

33. isNotEmpty and Inheritance with table per class hierarchy    forum.hibernate.org

[...] [...] ...

34. mapping a special hierarchy    forum.hibernate.org

another thing, I don't know your object model, but maybe the many-to-many relation is suitable fr you in the Circle - Arrow relationship... this assumption is based on that that you have defined a table name (arrows_of_circle). in this mapping the Circle-Arrow relation will be stored in the Arrow table's position column, you have to use many-to-many if you want a ...

35. in trouble with single table per class hierarchy mapping    forum.hibernate.org

Full stack trace of any exception that occurs: 55 [java] 2007-01-19 15:30:24,608 [main] ERROR org.hibernate.proxy.BasicLazyInitializer - CGLIB Enhancement failed: com.wachovia.cib.cdl.hiberfacade.OptionOrder 56 [java] java.lang.NoClassDefFoundError 57 [java] at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69) 58 [java] at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116) 59 [java] at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41) 60 [java] at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161) 61 [java] at org.hibernate.tuple.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:131) 62 [java] at org.hibernate.tuple.PojoEntityTuplizer.(PojoEntityTuplizer.java:55) 63 [java] at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64) 64 [java] at org.hibernate.tuple.EntityMetamodel.(EntityMetamodel.java:257) 65 [java] at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:412) 66 [java] ...

36. 1-to-1 multi level hierarchy mapping    forum.hibernate.org

37. Mapping Class hierarchy in multiple files    forum.hibernate.org

Hi, When you have a class design in which every class inherits from a common abstract super class how does one go about defining the corresponding HBM XML? In our database each concrete class is represented as a separate table. I was hoping to use the union-subclass strategy. All examples I've come across seem to imply that all hibernate mappings for ...

38. Mapping hierarchy as "disjoint" entities    forum.hibernate.org

39. Question about deep narrow hierarchy mapping.    forum.hibernate.org

40. Inheritance- combining tbl per hierarchy & tbl per subcl    forum.hibernate.org

(although we're using nHibernate, this should apply to Hibernate overall) -- I created an ADO version of our O/R layer for the first phase of our project (this means we already have the database tables). I'm now in the process of providing an nHibernate version. Note: The question is: How can I get an inheritance implementation that uses both tbl per ...

41. [INTERESTING] How to map a multilevel inheritanche hierarchy    forum.hibernate.org

Hi Pavol. There is no problem if I use a table per subclass strategy, with joined-subclass. But there is a legacy mapping for the first level of hierarchy using subclass with discriminator. Now, if the discriminator for Class B is "CLASSB" and the discriminators for class D and E are "CLASSD" and "CLASSE", can I do polymorphic queries? Can I query ...

42. Inheritance hierarchy in Primary Keys and Association issue!    forum.hibernate.org

Hi, I have the following scenario: Entity Class B & C extends A Entity Class E & F estends D Embedable Class EPK & FPK extends GPK (these are composite primary keys) Class E uses EPK & class F uses FPK. Class A has 1..2 association with D (meaning either 2E's or 2F's or E & F) 1..2 A<>-------------------- D GPk ...

43. Mapping a Hierarchy with join table, insert / update problem    forum.hibernate.org

Hi, I've got a problem mapping a tree-like hierarchy consisting of objects of a single class Node: Each Node has 0 or 1 parents and 0 or many children, i.e. a one-to-many relationship with other nodes via children and many-to-one via parents. Code: @Entity @Table(name = "NODE") public class Node { private Node parent; private ...

44. sqlRestriction on mapped hierarchy    forum.hibernate.org

If I have a mapped class hierarchy A extends B extends C B has a property private String surName; and accessors public String getSurName(){...} public void setSurName(String value) {...} Can I create a Criteria criteria = session.createCriteria(A.class); then add a Restrictions.sqlRestriction("soundex({alias}.sur_name) like soundex(?)", myName, Hibernate.STRING) Since the surName property is in class B the sqlRestriction can't find the correct column sur_name. ...

45. "Table per class hierarchy" mapping problem    forum.hibernate.org

Hi, All I have next hierarchy of classes: ParameterGenBo (POJO object) ^ Parameter ^ ParameterWithData ^ SicParameter I want to use "Table per class hierarchy" mapping. But for me this type of mapping is not working: instead of "SicParameter" I am getting object with "Parameter" class (I am checking by ID that correct db-record readed; also descriminator-valeue is set to "Sic"). ...

46. Issue with multi-level inheritance (table per hierarchy)    forum.hibernate.org

Hibernate version: 3.3.1 GA, with Apache Derby Embedded 10.4.2.0 I started from the sample about inheritance in the book Java Persistence with Hibernate, with a table per hierarchy mapping strategy (see Fig 5.2 on P.199). I extended the example by adding a RemuneratedAccount class that extends BankAccount. RemuneratedAccount has a unique property, rate of type float. So the hierarchy looks like: ...

47. Unique Column names mapping a deep value type hierarchy    forum.hibernate.org

Hello, I have a problem mapping a given (=fixed) deep class hierarchy with value type inclusion. Here is a simplified version of the problem: Code: @Entity class A { @Id String key; B b; C c; } @Embeddable class B { String bla; ...

48. how to map this hierarchy with JPA    forum.hibernate.org

Hello all, I asked this question on JavaRanch forums but could not get help.I appreciate if you can give me some clue. let's assume i have 3 classes,first one,lets say F1 is a a mapped super class second one,namely F2, is an entity derives from first one and third entity class named F3 is derived from second one F2 Code: ...

49. Can I put a class hierarchy mapping in different files?    forum.hibernate.org

Hi everyone; I have a deep class hierarchy with quite a few classes in 3 levels of the hierarchy. I have mapped them in one mapping file but it is getting messy with having so many elements in that file. My question is that; how can I put them in separate files and still achieve the polymorphic behavior? Thank you ...