Questions tagged [many-to-one]
1040 questions
0
votes
1 answer
Hibernate xml config file
I have a problem caused by a wrong hibernate mapping configuration while deploying the webapp from a war file in Tomcat.
The stacktrace of the error is the following:
Grave: Critical error during…

Hugo
- 1,662
- 18
- 35
0
votes
1 answer
Hibernate- Avoid many-to-many association- How to implement it right?
I'm a newbie to JPA and Hibernate.
I was able to set up some small basic examples as expected.
Now I'm trying to use it for a first real world project.
Studying the Hibernate best practices I found that you should avoid many-to-many relationships.…

user2093630
- 11
- 3
0
votes
0 answers
Hibernate Many-to-one or zero using tuplizer / proxy?
I have the following:
...

JRun
- 3,328
- 6
- 27
- 41
0
votes
2 answers
Hibernate ignore setting values on property with ManyToOne relationship
I have a Java Spring MVC controller application. It uses hibernate 4 and spring 3. Using Bitronix transaction manager
Here are some of my model classes
User.java
public class User implements java.io.Serializable {
private Integer…

iCode
- 8,892
- 21
- 57
- 91
0
votes
2 answers
@OneToMany and different primary key
I have small problem with JPA. I have three tables (OTHER table is not relevant here, but I add it just to explain why there is table USERS without PK):
ADDRESS
id (PK)
user_id (FK)
street
USERS
users_id(FK)
name_of_user
OTHER
users_id (PK)
And…

MicNeo
- 716
- 3
- 12
- 20
0
votes
0 answers
How to join with a column having comma separated values
I have written a query that joins multiple table and gets the result in the below format.
16-Jan-14 16-Jan-14 4 9860,9846,9861,11040,11038,11043 100
The comma separated values is a single column. Now I want to map this csv in the column to their…

user3243766
- 1
- 1
0
votes
1 answer
Field not initialized when persist object using JPARepository, @OneToMany <=> @ManyToOne
I have following entities:
MissionInfo:
@Entity
@Table(name = "mission_info")
public class MissionInfo implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue
private Long id;
@OneToMany(cascade={CascadeType.ALL})
…

Nikolay Shabak
- 576
- 1
- 7
- 18
0
votes
1 answer
How to create entity formtype from a non related entity (Symfony2)?
If you got for example the following Entities and relations:
PurchasedService * ---> 1 Service * ---> 1 ServiceCategory
how can you create a formType listing all entries from ServiceCategory within PurchasedServiceType?
As:
$builder
…

ZeroSpace
- 119
- 1
- 7
0
votes
1 answer
JPA OneToMany insert not setting the id's correctly
I have two entities, let's say
Person.java:
@Entity
public class Person implements Serializable {
@Id
@GeneratedValue(strategy = AUTO)
private long id;
@OneToMany(mappedBy = "personData", cascade = CascadeType.PERSIST)
private…

some12die4
- 100
- 1
- 11
0
votes
0 answers
Hibernate ManyToOne list only 1 relational entity
I'm using hibernate 3.6.10 and I'm facing this situation.
I have:
table A: a_id, a_name, a_desc
table B: b_id, b_name, a_id
and one A can be in many Bs
I want to do a one way ManyToOne join
So I've got:
@Entity
@Table(name = "B")
public class B…

pepepapa82
- 167
- 2
- 10
0
votes
1 answer
Doctrine2 Associations mapping and doctrine annotations
I've broken my head trying to set annotations for my 2 entities in order to use join tables.
I have 2 tables: user and cart.
Cart contains user ids with products which users selected.
1 user can have many products, so it's a ManyToOne…

yuriscom
- 550
- 3
- 17
0
votes
1 answer
Hibernate ManyToOne : Duplicate entry 'album1' for key 'TITLE exception
I am getting a duplicate key exception when I tried to use a ManyToOne relationship in hiberate. I believe that I can post images here.
These are my classes.
The Album Class
The Song Class
I am getting the below exception, when i tried to…

Arun Kamalanathan
- 8,107
- 4
- 23
- 39
0
votes
3 answers
many to one relationship: form validation doesn't create foreign key in database
I have a Many to one relationship between PostCategory & SubCategory like this:
SubCategory Entity:
namespace VisualImmersion\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SubCategory
*
*…

MeursaultF
- 209
- 1
- 9
- 20
0
votes
1 answer
Integrity constraint violation: many to one - cascade all
I'm new with hibernate and JPA, and I'm trying to do the next thing:
public class Centre extends JpaStandardVersionableEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "sq")
@SequenceGenerator(name = "sq", sequenceName =…

elcadro
- 1,482
- 3
- 21
- 45
0
votes
1 answer
Many-to-one unidirectional association: delete parent and set children column to null
I have two Java classes, Document and Category.
Document.java
public class Document {
private int document_id;
private Category category;
public void setDocument_id(int document_id) {
this.document_id = document_id;
}
…

JustTrying
- 592
- 4
- 9
- 23