Questions tagged [many-to-one]
1040 questions
0
votes
1 answer
Hibernate Many to one - Getting Duplicate Entry exception
I have 2 entity class called Student and University and relationship between student and university is Many-to-one which means many students can study in one university. My input jsp page basically will ask the university name and student email…

user977263
- 45
- 1
- 8
0
votes
1 answer
Criteria for retriving data involving multiple joins
I have four tables with sample data related with eachother as below
Employee
EMP_ID|EMP_NAME
---------------
101 |John
EmployeeDtl
EMP_DTL_ID |EMP_SKILLS |EMP_ID
-----------------------------------
1001 |Java |101
1002 |SQL…
0
votes
1 answer
Remove of entity not triggered when another managed entity holds a reference to it with CascadeType.PERSIST
My domain model: a uni-directional many-to-one mapping between payment and account.
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "ACCOUNT_TYPE")
public abstract class Account { ……

Peter Bollen
- 59
- 1
- 5
0
votes
1 answer
Hibernate: queries by example and many-to-one relationships
Let's say those are my entities:
Table1.java
@Entity
public class Table1 {
// Many to one
private Table2 table2;
// Raw attributes
// ...
}
Table2.java
@Entity
public class Table2 {
// Many to one
private Table3…

sp00m
- 47,968
- 31
- 142
- 252
0
votes
2 answers
JPA - Get collection from ManyToOne relationship
I have a table Post and Post_Image
@Entity
@Table(name = "post")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Post.findAll", query = "SELECT p FROM Post p"),
@NamedQuery(name = "Post.findByPostId", query = "SELECT p FROM Post p…

Jitendra
- 1,107
- 2
- 12
- 22
0
votes
1 answer
Mapping many-to-one foreign key Java EE
This is homework and I don't understand so help is appreciated. The system is an Olympic medal tally simulator.
We have an Events table and a Countries table:
statement.execute("create table EVENTS (EVENTNUMBER integer primary key not null,…

testpattern
- 2,382
- 1
- 25
- 29
0
votes
1 answer
NHibernate Hide dummy entity
I'm dealing with a legacy db, which uses dummy records for some empty relations.
Example: article has a relation to supplier. If an article has no supplier, a dummy supplier with ID 0 is assigned to the article, to satisfy the relation between both…

Geiserich
- 358
- 1
- 7
0
votes
2 answers
Using @Filter with @ManyToOne relation
I'm using Hibernate 3.6.7-Final and Spring 3.0.5.
I have entity like this
@Entity
public class Foo {
@ManyToOne
private Bar bar;
}
@Entity
public class Bar {
@Column
String group;
}
How can I use @Filter in Foo where I want to get…

Caesar Ralf
- 2,203
- 1
- 18
- 36
0
votes
3 answers
OpenERP : create new record ,one2many many2one relationship
I have created on2many field in class A and other field nombre (integer):
'Inventaire' : fields.one2many('class.b','id_classb'),
'nombre' : fields.integer('Nombre'),
In class b :
'id_classb' : fields.many2one('class.a', 'ID_classA'),
'ql' :…

Spirit angel
- 191
- 5
- 16
0
votes
2 answers
Hibernate mapping - many to one relationship
previously , this is how i map my "Activity" table. This table is storing CONTACT_ID and ACCOUNT_ID which link to Account and Contact table.
in this way

user998405
- 1,329
- 5
- 41
- 84
0
votes
1 answer
Creating child and grandchild paperclip records in a single controller action
I've been asked to modify an upload system that uses paperclip. Currently Users have many uploads, but now they want to extend this functionality by giving uploads pictures to help users better visualize the uploads.
So:
User has Many Uploads…

Noz
- 6,216
- 3
- 47
- 82
-1
votes
2 answers
Persistence Exception foreign key contraint fails in hibernate
I have defined the following two classes in hibernate
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
}
@Entity
public class PhoneNumber {
@Id
…

dnaiel
- 407
- 7
- 13
-1
votes
1 answer
ManyToOne and Column Conflict
error : @Column(s) not allowed on a @ManyToOne property: com.spring.mysql.test.api.model.Lancamentos.categoria
@ManyToOne
@Column(name="id_categoria")
private Categoria categoria;

Caio Genaro Guimarães
- 5
- 1
- 2
-1
votes
1 answer
How can I sum a group of a custom calculated field in SQL?
I have many shopper records who have a unique ID, there will be instances where a shopper with the same ID exists and I would like to sum up their shoppable_rated score and only return 1 result of the total sum of shoppable_rated for those IDs, so…

nootskej
- 69
- 7
-1
votes
1 answer
typeorm: Impossible to retrieve a joined value
I have the following config for an object:
export class Network {
@PrimaryColumn({ name: "id" })
id: string;
@Column("text")
url: string;
@ManyToOne(
type => User,
user => user.users,
{ nullable: true, onDelete: "SET NULL",…

Hermios
- 622
- 1
- 5
- 20