bidirectional 2 « Map « JPA Q&A





1. No cache hits with bidirectional one-to-one    forum.hibernate.org

// Populating the database Person p = new Person(); this.em.persist(p); Car c = new Car(); this.em.persist(c); p.setCar(c); this.em.flush(); // Populating the second-level cache this.em.clear(); this.em.find(Person.class, p.getId()); this.em.find(Car.class, c.getId()); // Clearing the first-level cache this.em.clear(); // At this point, the second-level cache contains both entities and the first-level cache is empty // I thought there would be no more SQLs after this ...

2. One-to-one - bidirectional - not lazy - N+1 select problem    forum.hibernate.org

Author Message VincentLH Post subject: One-to-one - bidirectional - not lazy - N+1 select problem Posted: Mon Sep 05, 2011 12:15 pm Newbie Joined: Mon Sep 05, 2011 11:27 am Posts: 4 Hello, I am not able to define a mapping that retreive A or B (linked with a single not lazy bidirectional One-to-One association) with a single select. ...

4. deferred constraints [bidirectional not null]    forum.hibernate.org

Hello, today I migrated from hibernate with innoDB mysql dialect to hibernate with postgresql. I use transactions managed by jboss. Already the first "insert testdata" function of my application does not work anymore. CUSTOMER has several relations to ADDRESS (billingaddress, shippingaddress, main address) with not null constraint. ADDRESS has a relation to CUSTOMER with not null constraint. My application creates a ...

5. Bidirectional one-to-many set, hashCode() & equals()    forum.hibernate.org

I am learning Hibernate. I have a bidirectional many-to-one relation between Groups and Subgroups. Group is the inverse side. I am using XML mappings: Code: ...

6. Problems with saving bidirectional associations    forum.hibernate.org

Hi, there is some trouble with saving a bidirectional association. I am setting the objects at both ends like it is described in the FAQ, but I always getting a SQL error update or deletion failed (row not found). Here is my hbm.xml file BESTELLUNG_ID_SEQ

7. Does one-to-one with foreign generator require bidirectional    forum.hibernate.org

Hi, I established a one-to-one mapping between a JHouse and a JRoof. As I wanted the id of the JHouse to be automatically generated, and the id of the JRoof to take on the value of the JHouse, I followed the FAQ which said I need something like this for JRoof: Code: ...

8. Does a one-to-manyrelationship have to be bidirectional?    forum.hibernate.org

I have been trying to get a simple one-to-many relationship to work. I have a Vendor that can have many contacts. So when I do Vendor.save() it should automatically persist the multiple contacts. Firstly is this possible? Do I have to use bidirectional? Please advise. Below are my mappings for vendor and contact respectively: Code:

9. one-to-one to be bidirectional or not    forum.hibernate.org

Newbie Joined: Tue Oct 07, 2003 9:43 am Posts: 16 Location: Chicago I am having problems with a fairly straight forward one-one mapping. I have a Vendor (parent) that has a one-to-one mapping with Contact (chils). The Contact table has a FK constraint on the Vendor table. I am getting a FK constrained violation primarily because HB is trying to save ...





11. bidirectional many-to-many deleting    forum.hibernate.org

And I find that bidirectional many-to-many is very hard to maintain. I write the following code to maintain a User's roles, it is very verbose. Any good idea? Code: public static void modifyUserRoles(String userId, String[] roleIds) throws HibernateException { Session session = openSession(); ...

12. bidirectional one-to-one association problem    forum.hibernate.org

Hi, Could really use some mapping help. I have an object graph where one class is associated to another via a 0/1. I implemented this with a one-to-one association. I defined the association at both ends initially. My problem is that when I create a new child class at the 0/1 end for an existing parent and persist the child, I ...

13. bidirectional one to may    forum.hibernate.org

Dear Sir, For the document hibernate_reference_mannual section 8.2, at the very beginning, it states that when a child is added, one insert and one update is done. I would like to know the update SQL will update which table, the parent or the child table to create the link?? And it two SQL is inefficient and may violate constraint, why the ...

14. idbag and bidirectional many-to-many    forum.hibernate.org

16. problems w/ bidirectional relationship    forum.hibernate.org

Author Message journeyman23 Post subject: problems w/ bidirectional relationship Posted: Wed Feb 04, 2004 2:05 am Newbie Joined: Wed Feb 04, 2004 1:25 am Posts: 8 Hello all, I am having problems with parent-child relationships. I have a parent class that has a one-to-many rela with the child class. the child class has a many-to-one with the parent. I ...





17. one-to-many with not null constraint without bidirectional    forum.hibernate.org

Hi, When I design my object model I try to avoid bidirectional associations. When our db guy design his database model he puts not-null constraints on foreign keys. I see in the doc that there is a limitation with this kind of stuff. I can't use an unidirectional one-to-many link if there is a not-null constraint on the element (in ...

18. Bidirectional many-to-many - constraint violation    forum.hibernate.org

Hi, I am having some difficulty with a bidirectional many-to-many relationship. I have read up on bidirectional relationships - but I am having some problem - most likely something I am doing wrong - something I misunderstand. I have two entities that have a many-to-many relationship. Ala: ...snip...

19. bidirectional outerjoin    forum.hibernate.org

20. one-to-one bidirectional via Xdoclet    forum.hibernate.org

Following up on this thread, I can't seem to the correct one-to-one mapping via hibernatedoclet: The error I got: Quote: net.sf.hibernate.MappingException: could not instantiate id generator at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82) at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:80) at net.sf.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:413) at net.sf.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:461) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:58) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:297) Caused by: net.sf.hibernate.MappingException: param named "property" is required for foreign id generation strategy at net.sf.hibernate.id.ForeignGenerator.configure(ForeignGenerator.java:64) Excerpt from the xdoclet tags between class Foo ...

21. bidirectional one-to-many mappingwith interface involved    forum.hibernate.org

... ... ...

22. Bidirectional one-to-many with Map at many-valued end    forum.hibernate.org

The docs explicitly state that Hibernate doesn't "currently" support bidirectional one-to-many with Map at the many-valued end. However, it appears to work fine with 2.1.1 -- even with a composite-index. (The collection retrieval selects the index column twice, but this appears to be harmless.) Is this just a case of the docs being out-of-date? Here's a flavor of what I'm doing: ...

23. Bidirectional relation with association class leads to error    forum.hibernate.org

Hello, I have two classes KoRisiko and KoMasznahme. Both do have a one-to-many association to a class named KoMasznahmenReferenz. It sould be possible to navigate from KoRisiko via KoMasznahmenreferenz to KoMasznahme and vice versa. The mapping files are as followes: TUKO101.SQ_KO_ART_risiko_DATA ...

24. Only one side of bidirectional relation working, why???    forum.hibernate.org

Hi, i've been trying to make this work, but every step i make i get another problem... here it is. I got two tables, Employee and Organization (many-to-one). I can access the organization through a employee object perfectly, but i cannot access the employees of one organization. In other words, the following code works. Code: Employee emp10 = (Employee)session.load(Employee.class, ...

25. Bidirectional delete & Second-level cache    forum.hibernate.org

I've read the documentation and the forum. And it seems that if you have a bidirectional relationship. You have to delete the object on both sides of the relationship. The problem with this is that I'm using the second-level cache and I have the following relationship Parent->Children & Child->Parent (one-to-many & many-to-one) The problem comes when the second-level cache contains the ...

26. Bidirectional one-to-many performance problem    forum.hibernate.org

I have a bidirectional assoc one-to-many from User to Order. When I was trying to populate the database to see how it works with some data in it, I found that after several hundred orders (2 or 3 hundreds) for a user, adding an order to the order collection of a user takes 300, 400 msec. on a PIV 2GHZ Win ...

27. Bidirectional HashMap    forum.hibernate.org

I have a Parent class with a HashMap of Child classes. Child has a parent attribute to refer to its Parent. I have successfully persisted the Map and both classes with Hibernate 2.1.3 to MySQL. I have had a good deal of trouble getting the classes to load from the DB - the parent attribute of Child is not set. It ...

29. Infinite Loop whith outer-join in bidirectional association    forum.hibernate.org

Author Message nwurtz Post subject: Infinite Loop whith outer-join in bidirectional association Posted: Thu Aug 26, 2004 9:41 am Newbie Joined: Thu Aug 26, 2004 8:50 am Posts: 6 Hibernate version:2.1.4 Oracle 9.2 Hi all, Ive got a parent-child bi-directional association where the childs key is composite (Child ID ,Parent ID). Everyhing works as expected whatever lazy is set ...

30. how to disassociate both ways in bidirectional many-to-many    forum.hibernate.org

... .. ... ...

31. Do I need to make this bidirectional?    forum.hibernate.org

Users belong to many Roles. Roles contain many Users. I want to be able to find all Users that belong to Role x. I want to be able to find all Roles that contain User y. Will a unidirectional mapping (like the one below) work, or do I need to make the relationship bidirectional? If I can keep it unidirectional, what ...

32. Simple Bidirectional Associations Question    forum.hibernate.org

By making a one-to-many association bidirectional I understand that it results in more efficient SQL and stops the not-null constraint problem on the 'many' table. Section 6.8 of the docs says that "Hibernate does not support bidirectional one-to-many associations with an indexed collection".. I need an indexed collection, so I'm I correcting in thinking that I just use a unidirectional association ...

33. Simple Bidirectional Associations Question    forum.hibernate.org

By making a one-to-many association bidirectional I understand that it results in more efficient SQL and stops the not-null constraint problem on the 'many' table. Section 6.8 of the docs says that "Hibernate does not support bidirectional one-to-many associations with an indexed collection".. I need an indexed collection, so I'm I correcting in thinking that I just use a unidirectional association ...

34. half bidirectional    forum.hibernate.org

hi, i want to have a sort of half bidirectional association. that is one end of the association should be in charge of managing the association but i want to be able to retrieve the other end of the association from the db and navigate back to the managing association. in principle this is possible with a bit of code...but i ...

35. polymorphic one-to-many bidirectional mappings    forum.hibernate.org

Hibernate version: 2.1.2 I have a class with several inverse relationships (one-to-many). [Entity] 1 ----> n [org.example.Relationship] It seems that I cannot have additional inverse relationships for the same column, even if they're mapped with insert=false, update=false and use a subtype of the class used to map the example above:

36. bidirectional many-to-many    forum.hibernate.org

2.13 Hi, I am trying to implement soft delete. I am using hibernate 2.13 with mysql, spring and tomcat. I have 2 classes Entity.java and EntityGroup.java. There is a bi-directional many-to-many mapping between Entity and EntityGroup. Entity maps to tbl_entity table and EntityGroup maps to tbl_entity_grp table. Both the tables have a column fld_record_status. When a group or entity is deleted, ...

37. bidirectional navigation of an assocaition    forum.hibernate.org

You can usually chose if you want an association bidirectional or unidirectional. In some cases, e.g. one-to-one between A and B with a foreign key in B's table, you might have to make it bidirectional if you want to navigate from A to B (that means you also need B to A). Those cases are very rare.

38. Bidirectional One-2-Many; cascade="none" cause sav    forum.hibernate.org

Lots of posts and information on this one. You need to mark the collection as inverse="true" which tells Hibernate that you will manage the relationship from the child side of things, otherwise Hibernate thinks the relationship is managed from the parent side. So, what happens is when you delete the parent Hibernate removes the relationship first by updating the child object ...

40. Bidirectional many-to-many mapping....    forum.hibernate.org

Newbie Joined: Sat Feb 05, 2005 1:50 pm Posts: 2 Hi!... Well, I think I doing a very stupid error, but I'm not able to find it... I was following the example of Hibernate in Action to create a many-to-many association. This many-to-many will be between a class: Category and a class: Item. To do so, I'm using a third database ...

41. Bidirectional association - many to one.    forum.hibernate.org

If I have a bydirectional association i.e. classA.addClassb(b) and inside the addClassb() method, i say b.setClassA(this), what must I do to delete classB from classA. The setup I have now is I'm storing instances of classB in a set that is an attribute of classA. When I remove the entry, I'm getting the following exception net.sf.hibernate.PropertyValueException: not-null property references a null ...

42. Bidirectional association equal to two unidirectional assoc.    forum.hibernate.org

This is a bidirectional association: A <---> B Is this equal to modelling it as two unidirectional relations? Code: ---> A B <--- One of our external coworkers states that they are NOT equal. He says that they have different consequences. I don't think so. Whats right, whats wrong? Please tell me. ...

43. Example of one-to-one bidirectional relationship    forum.hibernate.org

44. many-to-many bidirectional mapping with uuids    forum.hibernate.org

Newbie Joined: Thu Feb 17, 2005 11:50 pm Posts: 4 I've spent all day searching for an example of this, but can't seem to find a solution. I have recreated the problem in a simpler environment (running with a MySQL db): 2 classes, JitUser and JitGroup. Code: package com.digilore.model.bean; import java.util.HashSet; import java.util.Set; /** * @hibernate.class * table="JitGroup" ...

45. PropertyValueException - Bidirectional references gets cut    forum.hibernate.org

Hello, I better give a short summary at first. My app is a comlex xml->database importer. The mass data consists of computer systems (class CSystem) and their properties (class Property). I extracted 4 classes to isolate my problem, incl. a testcase. First I delete all CSystem's in my database. Then I import some dummy data (to avoid the xml-parsing). Works very ...

46. Bidirectional association    forum.hibernate.org

can anyone help me understand the bidirectional association in a many-to-one relationship? I have an employee who works at a division (many employees work at A division) I want to map the FK of divisionID to the employee: Code:

47. many-to-one bidirectional relationship trouble    forum.hibernate.org

Newbie Joined: Thu Apr 14, 2005 8:21 am Posts: 5 Hibernate version: 3.0 Mapping documents: Code:

48. one-to-one bidirectional results in redundant queries    forum.hibernate.org

Hibernate 2.1.8 Hi, I have a Parent-Child relationship where the parent has one child and the child has one parent (no less, no more). In DB, the child is the one that has the FK to the parent id. I've mapped the parent ot have a and the child to have a When I'm loading all the parents I'm ...

49. StackOverflowError: bidirectional many-to-many    forum.hibernate.org

Author Message briankuhn Post subject: StackOverflowError: bidirectional many-to-many Posted: Thu May 12, 2005 2:31 am Newbie Joined: Tue Sep 28, 2004 2:03 pm Posts: 9 Location: Fullerton, CA I have two objects to persist; Account and Role. Account has a String username, a String password and a Set of Roles. Role has a String name, and a Set of ...

50. Problem with bidirectional mappings...    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp [b]Hibernate version:3.0[/b] [b]Mapping documents: Parent.hbm.xml ...

80. A bidirectional many-to-one association with read-only cache    forum.hibernate.org

>>You should always finish initializing an object before calling save() or persist(), or you will see this kind of inefficient SQL. >Can you elaborate, please? "I am thinking of a number between 1 and 10..." I think he is trying to say that you're continuing to change your objects somehow before you commit. One of the little surprises of Hibernate that ...

81. bidirectional relationship problem    forum.hibernate.org

have 2 classes: Employee: Job:

82. A bidirectional one-to-many association on a join table    forum.hibernate.org

Newbie Joined: Thu Jan 05, 2006 1:37 am Posts: 2 Component/s: hbm2java Affects Version/s: 3.1beta2 Fix Version/s: None parent.hbm.xml: hi_value next_value 100 child.hbm.xml

84. Bidirectional associations question    forum.hibernate.org

Hi, In my application I have 2 classes which have a typical one-to-many bidirectional association. The mapping is also the typical one, where the parent has a set with inverse="true" and cascade="save-update", and the childs have a many-to-one with cascade="none" Then different screens are given to the user so he can add/edit/delete parents or childs. I mean, there is a screen ...

85. Fetching in a bidirectional association    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: Hibernate 3.1 Mapping documents: Hi, I don't know if I get it right but... I am dealing with a simple association between two entities: Code: |Server|1------>1..*|Authorities| then my classes look like: Code: public class Server implements java.io.Serializable { public Server(String name, String address) { ...

86. bidirectional many-to-many update from both ends    forum.hibernate.org

bigor wrote: HI, I was reading "Hibernate in Action" about many-to-many bidirectional relationship. It says that this kind of relationship has to have one end which will actualy do the updates to the database when calling saveOrUpdate. I am wondering why can't Hibernate update the database form both sides? Or can it? You can update the database from both ends. Set ...

87. facing Problem with bidirectional realtionship    forum.hibernate.org

Hi All I am using hibernate 2.0.I am facing some problem with bidirectional relationship. Here is my mapping file contents. Text public ...

88. bidirectional association not working..    forum.hibernate.org

In my Parent.hbm.xml: ... In my Children.hbm.xml: ... When I do session.saveOrUpdate(), everything get's populated Except the foreign key in Children table i.e parent_id value is shown null in the Children table. Am trying these ...

89. one-to-one bidirectional mapping    forum.hibernate.org

Hi, I am new to hibernate. I am facing some problem in creating one-to-one relationship bidirectional. In my scenario, I have 2 tables named Basket_item and Special_Price_Request. both tables are 1:1 mapped and PK of Basket_Item is FK in Special_Price_Request, that is Basket_Item is Parent table and Special_Price_Request is child table In existing solution , I can get the SpecialPriceRequestDO by ...

90. one-to-one bidirectional mapping    forum.hibernate.org

Hi, I am new to hibernate. I am facing some problem in creating one-to-one relationship bidirectional. In my scenario, I have 2 tables named Basket_item and Special_Price_Request. both tables are 1:1 mapped and PK of Basket_Item is FK in Special_Price_Request, that is Basket_Item is Parent table and Special_Price_Request is child table In existing solution , I can get the SpecialPriceRequestDO by ...

91. Cascading in bidirectional relationships    forum.hibernate.org

I have a relationship that looks something like this: Code: class Parent { @OneToMany(cascade=CascadeType.ALL, mappedBy="parent") Set children; @OneToOne @JoinColumn(nullable=false) Child defaultChild; public void Parent() { ...

92. Inheritance parent-child bidirectional association    forum.hibernate.org

@Entity @Inheritance(strategy=InheritanceType.JOINED) Reservable { private Long id; @Id @GeneratedValue(strategy=GenerationType.AUTO) public Long getId() { return id; } public void setId(Long id) { this.id = id; } ...

93. column problem on a bidirectional one-to-many association    forum.hibernate.org

Hello, I'm having some problems with a bidirectional one-to-many association where the associated entity is a joined subclass. I have a base class called GamePrototype : Code: @Entity @Inheritance(strategy = InheritanceType.JOINED) public class GamePrototype { private long Id; private Brand brand; @Id ...

94. Newbie question: many-to-many bidirectional mapping    forum.hibernate.org

Newbie Joined: Wed Apr 19, 2006 7:54 am Posts: 6 Hibernate version: 3.1 Mapping documents: Code:

95. Bidirectional mapping - fail to save children    forum.hibernate.org

Author Message balderman Post subject: Bidirectional mapping - fail to save children Posted: Mon May 01, 2006 9:25 am Beginner Joined: Fri Feb 24, 2006 12:52 pm Posts: 30 Description: I want to create a new version of the PolicyImpl class in the DB. So I have code that clone the object. After cloning the object I have problem ...

96. Bidirectional mapping - fail to save children    forum.hibernate.org

Author Message balderman Post subject: Bidirectional mapping - fail to save children Posted: Mon May 01, 2006 9:27 am Beginner Joined: Fri Feb 24, 2006 12:52 pm Posts: 30 Description: I want to create a new version of the PolicyImpl class in the DB. So I have code that clone the object. After cloning the object I have problem ...

97. one-to-one bidirectional association saveorupdate()    forum.hibernate.org

I have created a one-to-one bi directional association using foriegn key between two tables and able to get both the tables fields. Can anyone help me how the saveorUpdate works with this kind of association.I am setting one object(table) into another using set method and passing the object to save.Only one table is getting updated or saved. How do I update ...

98. bidirectional many-to-many tree (parent, child = same class)    forum.hibernate.org

Hi, I needed to create mapping for graph structure. It looks like normal tree with some exception. Every node has 0-N children and every node has 0-N parents (instead of only one). Node's children should be ordered, parents not. I can do mapping for normal tree but I'm totally lost with this. I read reference documentation and HIA, but can't make ...

99. Garbage Collection of objects with bidirectional association    forum.hibernate.org

Say I have two objects, Parent and Child, and they both have one-to-one mappings as below, Code: ... ...

100. bidirectional many-to-many returning null objects    forum.hibernate.org

Newbie Joined: Wed Dec 07, 2005 10:05 pm Posts: 2 When I use the below mapping I get null results back from the getParents() method if parents is mapped with inverse="true", while the getChildren() method returns accurate results. If I change so that children is mapped as inverse="true" I get the opposite. getParents() return accurate results and getChildren() returns null values. ...