Questions tagged [many-to-one]
1040 questions
0
votes
1 answer
Multiple mapping One to many in Jpa
If I've, in a single entity A, multiple relations (many to one) towards an entity B (annotated with one to many)? Do I've to put an annotation for each occurrence of A in B?
Example:
Entity A:
@Entity
@Table(name = "patient")
@TableGenerator(name =…

andPat
- 4,153
- 7
- 24
- 36
0
votes
1 answer
Hibernate @Version annotation and object references an unsaved transient instance
My New Project is in Hibernate 4.2.5.Final and Spring. After Login, I am storing the user object in the session.
Now after successful login, I need to insert one record in the application log. Here are the classes:
Class BaseEntity
…

Senthil Muthiah
- 97
- 1
- 3
- 14
0
votes
1 answer
Many to one -> MySQLSyntaxErrorException: Result consisted of more than one row
I have web application developed in JSF2 in which i have to persist two entity class with a One to Many bidirectional relationship. when I try to persist a record of a table (Documenti_tg) I have this error :
Caused by:…

Claudioc
- 53
- 1
- 10
0
votes
1 answer
How to create dynamic query using criteriaquery for many-to-one
I have Person as one to many relationship with Address in JPA .
@Id
@Column(name="personid")
private Long personId;
private String firstName;
private String lastName;
private String email;
@OneToMany(cascade =…

Achyut
- 377
- 1
- 3
- 17
0
votes
1 answer
ManyToOne default value
I have an application with default values persisted in the database.
For example, a class Person with an attribute City wich default is "New York" with the id 0.
@Entity
public class Person {
@Id
private Integer personId;
private String…

Nicolas Trichet
- 204
- 2
- 9
0
votes
1 answer
Rails 3.2 Associations and :include
I have some troubles to make an association between 2 tables.
I have Users who can write Posts
Here is my migration file :
class LinkUsersAndPosts < ActiveRecord::Migration
def change
add_column :posts, :user_id, :integer
add_index …

Joe Bow
- 101
- 1
- 4
0
votes
1 answer
ORM relation mapping issues in Doctrine and ZF2
I was puzzled by Doctrine\ORM\Mapping issue. I have two entities and they are Many-To-One, Unidirectional releationship. I want to operate Chipinfo(add/update/delete) without impact on producer. Only persist Chipinfo while no persist…

shijie xu
- 1,975
- 21
- 52
0
votes
1 answer
JPA: several relations
I have much trouble with JPA and the right annotations and tried a lot of annotations and combinations like @JoinColumn, mappedBy and so on, but still get errors. I use EclipseLink (JPA 2.1).
I have the owner class Store:
@Entity
public class Store…

user2047688
- 45
- 1
- 10
0
votes
0 answers
EF5/Code First relations work at database level but not in the assembly
I'm transitioning from nHibernate to EF5 and am having problems with mapping relations. Working with a conventional one-to-many relation let's call it Instructor/Course:
public class Course
{
public Course()
{
Instructor = new…

justSteve
- 5,444
- 19
- 72
- 137
0
votes
1 answer
Many-to-one cascade delete NHibernate results in RESTRICT (MySQL 5)
I've a simple category class. Each category can have zero or more children of type category. Therefore I have chosen to register the parent of a category, which can be null or the id of another category. When a category is deleted, all its children…

Mike de Klerk
- 11,906
- 8
- 54
- 76
0
votes
1 answer
Why does Salesforce consider this simple parent-to-child relationship SOQL query not valid?
A CaseMilestone record can have one Case record and one Case record can have many CaseMilestone records.
So this works:
SELECT Id, (SELECT Id FROM CaseMilestones) FROM Case
Similarly, a CaseMilestone record can have one MilestoneType record and one…

J Smith
- 2,375
- 3
- 18
- 36
0
votes
1 answer
How to map Hibernate entity where a primary key component and the foreign key have the same column name?
I have problem with composite primary key and Foreign key having the same column name.
Example
Table A
PK (ID , NEW_ID)
Table B
PK (ID, NEW_ID)
FK (A_ID, NEW_ID)
I have the relationship of Entity B mapped to A in this…

mohan
- 239
- 2
- 3
- 11
0
votes
1 answer
Java Hibernate Fetch Entity loads on setting a property on it
i am trying to get some students in Hibernate in many-to-one relationship School-Students. later i am trying to get the Teachers of the school when the students belongs..
here is my code
public ArrayListsearch(Date dateBorn)
{
Session…

chiperortiz
- 4,751
- 9
- 45
- 79
0
votes
3 answers
JPA - OneToMany relationship not loading children
I am trying to configure this @OneToMany and @ManyToOne relationship but it's simply not working, not sure why. I have done this before on other projects but somehow it's not working with my current configuration, here's the code:
public class…

Joe Almore
- 4,036
- 9
- 52
- 77
0
votes
1 answer
NHibernate Many-to-Once Cascade
I have created the mapping shown below between Invoice and InvoiceDetail. When trying to update an Invoice, I notice an update statement for User as well. Why should “User” be updated when we have set cascade ="none"?