Questions tagged [bidirectional-relation]

98 questions
3
votes
1 answer

Bidirectional dependency of two objects

BACKGROUND I have the following: class Fire extending Element, class Wood extending Element, class Tile which composites Element. The Tile class represents a tile in a world/screen/canvas, and has some graphical and logical functionality in it. It…
Alon Emanuel
  • 172
  • 3
  • 10
3
votes
0 answers

ternary relationship with @ElementCollection - left join fetch misbehaving

JPA 2, Eclipselink 2.3.2 I'm trying to model a ternary relationship with two @ElementCollection as opposed to two @OneToMany's mainly so I can make the junction object an @Embeddable instead of an @Entity and avoid needing an @Id for the nested…
wrschneider
  • 17,913
  • 16
  • 96
  • 176
2
votes
2 answers

How to prevent retrieval of all entries from bidirectional ManyToMany collection while adding new entry

I would like to know how to prevent retrieval of all entries from bidirectional ManyToMany collection while adding new entry into that collection. I have User entity, that has bidirectional relationship with UserGroup entity. When I add group in…
2
votes
3 answers

What would my SQL statement be to insert "Arnold Schwarzenegger" and "Hasta la vista baby" into these two empty SQL tables?

What would my statement be to insert "Arnold Schwarzenegger" and "Hasta la vista baby" into the following empty SQL tables? The title of this question was originally going to be "How to insert the first records into SQL tables with bidirectional…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
2
votes
1 answer

Many to many relationship for same type entity

I have an entity as below. I am curious if it is possible to create a relationship as I will be describing with the example: I am creating 2 Person entities Michael and Julia. I am adding Julia to Michael's friends set. After that I am retrieving…
el nino
  • 129
  • 1
  • 3
  • 10
2
votes
1 answer

Does a hibernate many to many relationship have to use the @ManyToMany annotation and use a join table?

I searched a lot of examples on google related to the Hibernate many to many relationship. I found that all posts use the join table annotation (@JoinTable) in this kind of relationship. Do I have to use @JoinTable in a many to many? If yes, why?…
frank
  • 1,169
  • 18
  • 43
2
votes
0 answers

How to bidirectionally bind two DoubleProperties related through a given transform and its inverse

Given two properties such as DoubleProperty x; DoubleProperty y; and given two functions that are inverses of each other, such as DoubleUnaryOperator xToY = x -> Math.exp(x); DoubleUnaryOperator yToX = y -> Math.log(y); what is the simplest way to…
Museful
  • 6,711
  • 5
  • 42
  • 68
2
votes
2 answers

Adding a newly persisted entity to a list of entities held by the inverse side of a relationship so as to maintaining a bidirectional relationship

Given two entities Department and Employee forming a one-to-many relationship from Department to Employee. Since the relationship is quite intuitive, I am leaving out the entity classes. The following segment of code, simply persists an entity…
Tiny
  • 27,221
  • 105
  • 339
  • 599
2
votes
2 answers

It is possible to use bidirectional dependency in UML class diagram?

I have 2 classes, they are more complex but that is not important.. How should I draw this dependency in UML class diagram ? I'm not sure how it should look like public class A { private void foo(B b){ .... } ... } public class B { …
Pauli
  • 538
  • 8
  • 22
2
votes
0 answers

Hibernate bidirectional mapping, saving child does not update parent

The first assert statement passes but the second does not. Stepping through the code, the database is being updated properly at each commit. However, the primary entity does not appear to update when the secondary entity object updates. Entity…
stephenwebber
  • 633
  • 5
  • 16
2
votes
2 answers

NHibernate Many to Many table is not updated

I have a 3 tables which are "News", "Tags", "News_Tags" with Many-To-Many relationship. With the following mapping the "News" and "Tags" table have been updating, but "News_Tags" has not been updated. Can anyone help me? News:
Daoming Yang
  • 1,325
  • 3
  • 20
  • 41
2
votes
1 answer

JPA - How to update a collection in a bi-directionnal OneToMany/ManyToOne relation

I have an owner (Category) and a customer (Forum) entities designed this way: Category ... @OneToMany( fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "category" ) @OrderBy( "position" ) private List
Med
  • 628
  • 9
  • 29
2
votes
2 answers

maintaining integrity in bidirectional relations and Entity Framework

I am looking for a best-practice regarding the maintaining of bidirectional relations between C# POCO's that are being persisted with Entity Framework. A Family has zero to multiple familyMembers and a Person always has one family. Now when I …
peterrus
  • 651
  • 2
  • 6
  • 18
2
votes
3 answers

Symfony2 Doctrine many-to-many bidirectional save form type

I have a problem saving entities with forms. The relationship that gives me problems is many-to-many bidirectional. Agent Entity /** * @var \Doctrine\Common\Collections\ArrayCollection $agentLists * * @ORM\ManyToMany(targetEntity="AgentList",…
Mauro
  • 1,447
  • 1
  • 26
  • 46
1
vote
1 answer

Can't clear a list of related entity beans from an entity bean

I'm trying to run the code below, but I keep getting the error "Cannot merge an entity that has been removed". My DB tables look like this: banner -id banner_period -id -banner_id -date My Java code: Banner b =…
Bjørn Stenfeldt
  • 1,432
  • 1
  • 18
  • 25