Questions tagged [many-to-one]
1040 questions
8
votes
1 answer
envers multi level entity revision howto
User have n Contacts. A Contact can have a localized Comment (Comments are shared between Contacts). Java Beans:
@Audited
@Entity
public class User {
@OneToMany(fetch = FetchType.EAGER,
cascade = CascadeType.ALL,
…

Andreas Höhmann
- 93
- 7
8
votes
2 answers
Trying to understand the importance of an owning side of a one-many relationship in ORM
Even though my question is worded specifically to the way Entity relationships are depicted in the Play framework, which uses Hibernate, I am sure this is a general concept.
When we have a one-to-many relationship, we are always asked to specify…

Parag
- 12,093
- 16
- 57
- 75
8
votes
9 answers
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on references an unknown entity
I am receiving the following Hibernate Exception:
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on cz.rohan.dusps.model.Switchport.konfiguracniTemplateAccess references an unknown entity: cz.rohan.dusps.model.KonfiguracniTemplate
…

Martin
- 97
- 1
- 1
- 3
8
votes
2 answers
JSON content for POST request @ManyToOne relationship in Java Spring
I have two models:
Class One:
import javax.persistence.*;
import java.util.Set;
@Entity
public class One {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@OneToMany(mappedBy = "one")
…

rsu8
- 491
- 4
- 10
8
votes
4 answers
Hibernate creating N+1 queries for @ManyToOne JPA annotated property
I have these classes:
@Entity
public class Invoice implements Serializable {
@Id
@Basic(optional = false)
private Integer number;
private BigDecimal value;
//Getters and setters
}
@Entity
public class InvoiceItem implements…

Mateus Viccari
- 7,389
- 14
- 65
- 101
8
votes
2 answers
How do I left join tables in unidirectional many-to-one in Hibernate?
I'm piggy-backing off of How to join tables in unidirectional many-to-one condition?.
If you have two classes:
class A {
@Id
public Long id;
}
class B {
@Id
public Long id;
@ManyToOne
@JoinColumn(name = "parent_id",…

jbarz
- 582
- 6
- 17
7
votes
2 answers
Spring MVC with Hibernate - OneToMany mapping in form
I have Car and Rental models conntected OneToMany relation:
@Entity
public class Rental {
private Long id;
private Car car;
private User user;
@Id
@GeneratedValue
@Column(name = "RENTAL_ID")
public Long getId() {
return id;
}
public void…

bontade
- 3,194
- 6
- 48
- 75
7
votes
3 answers
Hibernate Many-To-One Foreign Key Default 0
I have a table where the the parent object has an optional many-to-one relationship. The problem is that the table is setup to default the fkey column to 0.
When selecting, using fetch="join", etc-- the default of 0 on the fkey is being used to…

user573648
- 101
- 1
- 1
- 5
7
votes
1 answer
Hibernate criteria query using Max() projection on key field and group by foreign primary key
I'm having difficulty representing this query (which works on the database directly) as a criteria query in Hibernate (version 3.2.5):
SELECT s.*
FROM ftp_status s
WHERE (s.datetime,s.connectionid) IN (SELECT MAX(f.datetime),
…

Tom S
- 310
- 2
- 4
- 12
7
votes
1 answer
Two attributes sharing the same OneToMany relationship to one entity Symfony2
Let's first describe my situation. I am using Symfony2 and I have a problem with a relationship between my entities.
I have two entities that are linked together. The two entities are AssociationQuestion and AssociationPossibleAnswer. I am currently…

Etienne Noël
- 5,988
- 6
- 48
- 75
7
votes
3 answers
Doctrine @UniqueEntity with ManyToOne fields?
I'm trying to create a UniqueEntity with 2 fields (both are ManyToOne fields).
The code is as follow:
/*
* @ORM\Table()
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity(fields={"user", "connect"})
*/
class UserConnect
{
/**
*…

Ben
- 674
- 9
- 21
6
votes
2 answers
NestJS - TypeORM - ManyToOne Entity is undefined
I am trying to link to entities Child & Client
So I have created 2 entities :
// src/children/child.entity.ts
@Entity()
export class Child extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstname: string;
…

rcarette
- 111
- 2
- 10
6
votes
2 answers
Django -- where is the many to many picker widget?
For each row of table A, I want to be able to add one or more rows from table B.
The Django admin has an example, the user permissions picker -- I attach a screen shot.
Each user can have any number of permissions. The permissions start on the…

Rick Graves
- 517
- 5
- 11
6
votes
1 answer
JPA Hibernate Lazy many-to-one fetch proxy
I'm using JPA 2.1 and Hibernate 4.3.7
I tried to tuned my app so I turn relationships to lazy and fetch only what I need them
I have a problem with the many-to-one relationships, when turn to lazy when I load the entity again Hibernate replace the…

kwisatz
- 1,266
- 3
- 16
- 36
6
votes
3 answers
Another entities-cannot-be-cast-to-javassist-util-proxy-proxy
Following thread [entities cannot be cast to javassist.util.proxy.Proxy, i do have now a server side error ( tks thomas)
I wasn't able to face the real problem within my app.
java.lang.ClassCastException:…

Tanc
- 667
- 3
- 6
- 25