Questions tagged [one-to-one]

Refers to the quantity of an entity as a relationship to another entity. Meaning that for every instance of an entity, there is a single related instance of another entity.

Refers to the quantity of an entity as a relationship to another entity.

Meaning that for every instance of an entity, there is a single related instance of another entity.

1496 questions
12
votes
1 answer

@OneToOne and @JoinColumn, auto delete null entity , doable?

I have two Entities , with the following JPA annotations : @Entity @Table(name = "Owner") public class Owner implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private long id; …
smallufo
  • 11,516
  • 20
  • 73
  • 111
11
votes
7 answers

JPA @OneToOne throws Error when mapped to an abstract @Entity with subclasses

I have a problem when an Entity is mapped to another Entity which has a direct implementation on its subclasses. See sample mapping below: @Entity class Location { @OneToOne @JoinColumn(...) private Person…
sevenFLiP
  • 188
  • 2
  • 10
11
votes
5 answers

Easy Way to See if Two Columns are One-to-One in Pandas

Working with data in Python 3+ with pandas. It seems like there should be an easy way to check if two columns have a one-to-one relationship (regardless of column type), but I'm struggling to think of the best way to do this. Example of expected…
user1895076
  • 709
  • 8
  • 19
11
votes
5 answers

Hibernate OneToOne mapped entity sets all properties to null

Using Hibernate 5, Spring 4 Please consider below codes and mapping between two entities: User class @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") private TruckOwner truckOwner; //getter setters below TruckOwner…
user7041082
11
votes
1 answer

Unable to determine the principal end of an association between the types

Here is the situation. There are two type of ElectricConsumer ie CommercialConsumers & DomesticConsumers(Quaters) and one Quater is allocated to one Employee. Below is my code but encountring the exception . Unable to determine the principal end…
11
votes
2 answers

NHibernate one-to-one mapping where second table data can be null

I have an existing database with the table Transactions in it. I have added a new table called TransactionSequence where each transaction will ultimately have only one record. We are using the sequence table to count transactions for a given…
SteveBering
  • 947
  • 1
  • 12
  • 30
11
votes
2 answers

Hibernate @OneToOne executes multiple queries even with @Fetch(FetchMode.JOIN)

Consider and Employee and Address relationship. There is a One-to-one mapping between Employee and Address. Following are models: @Entity @Table(name = "Address") public class Address { @Id @GeneratedValue @Column(name = "addressId") …
Sanket Meghani
  • 885
  • 2
  • 14
  • 22
10
votes
2 answers

NHibernate one-to-one mapping, non-primary keys

Can't get NHibernate to generate the correct query. It keeps using the primary keys of the two tables I'm joining for the one-to-one relationship, and I can't figure out how to specify the foreign key in one of the tables. tableA tableB { aID, …
MonkeyWrench
  • 1,809
  • 2
  • 24
  • 48
10
votes
3 answers

Django Admin: How to display value of fields with list_display from two models which are in oneToOne relation?

I belive that the answer to my problem is simple, but I can't find it anywhere. Here is my predicament. I have two models: Member and MemberDetail, which are in oneToOne relation like this: class Member(models.Model): ID =…
sninja
  • 401
  • 1
  • 6
  • 14
10
votes
1 answer

1-to-1 relationship causing exception: AssociationSet is in the 'Deleted' state. Given multiplicity constraints

I have set up a 1-to-1 relationship using EF code first following the method prescribed here: Unidirectional One-To-One relationship in Entity Framework My mapping looks like this ... protected override void OnModelCreating(DbModelBuilder…
9
votes
2 answers

Why hibernate perform two queries for eager load a @OneToOne bidirectional association?

i have entity A that has-a B entity, and B has-a A with @OneToOne bidirectional association. Now, when i findall A records, hibernate perform two queries with a left outer join on B, something like this: select a.id, a.id_b, a.field1, b.id, b.field1…
blow
  • 12,811
  • 24
  • 75
  • 112
9
votes
1 answer

OneToOne + No Foreginkey + Unidirectional + Datamissing => EntityNotFoundException

From a legacy system, we have 1 table (Entity) and 1 view (UserDetail) with no constraints but with relations. Entity | Id | Desc | Created_By |... UserDetail | UserId | F_Name | L_Name |... CreatedBy has the userid of the user who created that…
raksja
  • 3,969
  • 5
  • 38
  • 44
9
votes
5 answers

One-to-one mapping data structure (A,B) with getKey(B) in O(1)?

This question was initially misphrased, see the EDIT below. I'll leave it up for context. I've been thinking about smart ways to build a bijective (i.e. one-to-one) mapping. Mapping a function A->B (many-to-one) is basically what HashMap(A,B) does.…
G. Bach
  • 3,869
  • 2
  • 25
  • 46
8
votes
1 answer

How to map OneToOne relationship between POJOs using @JsonManagedReference and @JsonBackReference

I have read http://vard-lokkur.blogspot.com/2010/10/json-jackson-to-rescue.html http://vard-lokkur.blogspot.com/2010/10/json-jackson-serialization-narrowed.html http://www.cowtowncoder.com/blog/archives/2010/09/entry_418.html looking for…
Steinway Wu
  • 1,288
  • 1
  • 12
  • 18
8
votes
1 answer

One-to-One bi-directional mapping with composite primary key

Could someone please help me with doing the bi-directional one-to-one JPA mapping for the following relationship using the composite primary key using Hibernate/JPA?
skip
  • 12,193
  • 32
  • 113
  • 153