Questions regarding the implementation of one to many relations using Hibernate ORM framework
Questions tagged [hibernate-onetomany]
281 questions
0
votes
1 answer
How do I get an object in the "many" part from a One-To-Many unidirectional relationship?
I don't know how to exactly express what I'm looking for, so I'll explain what I have and then what I'm trying to do.
I have a Class model, which has 2 classes with a One-To-Many unidirectional relationship.
public class TaxType extends Entity…

fkchaud
- 53
- 7
0
votes
1 answer
Is it good idea hold only entity id instead of Set for less join operation
I m trying to implement a application. In this application i have an entity name comment,answer,question. Question,answer and comment has comments so i m planning to create a Commentable class and all of three class can extend Commentable. In this…

ilkerbfl
- 23
- 1
- 4
0
votes
2 answers
Hibernate One-To-Many Mapping, printing mapped lists
I have used One-to-Many Mapping in my project. I have stored a list of clicks for every user.
But when I retrieve the list by calling getClicks() methodm Hibernate returns list in different format.
Something like…

okcomputer_kid
- 491
- 6
- 12
0
votes
1 answer
Hibernate OneToMany relationship: not mapped to a single propery
I have two tables with these primary keys:
TABLE A TABLE B
---------- ----------
| colA |-----> | colX |
| colB |-----> | colY |
| colC |-----> | colW |
…

Fabrizio Stellato
- 1,727
- 21
- 52
0
votes
1 answer
How to have a log or history table for User in MySQL and Hibernate
I am confused in creating a database design for my application. I am using MySql as database and spring and hibernate.
My requirement is:
I have a user table with roles admin/user and I have a device table. In the device table I have a column called…

Madhu
- 53
- 1
- 11
0
votes
0 answers
OneToMany Hibernate Failed To Save
I have problem with OneToMany saving problem using hibernate.
@Entity
@Table(name="lecturer")
public class LecturerEntity extends BaseEntity implements Serializable{
private static final long serialVersionUID = 446089492592652000L;
@Id
…

kukuh utama
- 11
- 2
0
votes
4 answers
Hibernate fetch parent and all children if any of children meet criteria
I have 2 tables : Parent and Child and oneToMany relation between Parent and Child
@Entity
@Table(name="PARENT")
public class Parent {
int parentID;
String marritalStatus;
List children;
//getters and setters
…

DaenKhaleesi
- 179
- 2
- 5
- 17
0
votes
2 answers
Hibernate OneToMany, natural PK
I've got problem with setting up OneToMany relationship.
My DB schema:
TABLE PARENT (
VENDOR,
CHANNEL,
CREATEDATE,
REFID,
...
)
UNIQUE INDEX PK_PARENT (VENDOR, CHANNEL, CREATEDATE, REFID)
TABLE CHILD (
REFID,
NAME,
)
UNIQUE INDEX PK_CHILD (REFID,…

voncuver
- 65
- 6
0
votes
1 answer
Hibernate: overriding the (entity) superclass's OneToMany mapped field?
Is it possible to make a subclass (entity) override a OneToMany mapping from its superclass (entity)? Currently I'm getting "HibernateException: Found shared references to a collection", presumably because the superclass entity and subclass entity…

Kevin C.
- 11
- 4
0
votes
1 answer
Does hibernate allow to define the order of saving child elements
Does hibernate allow to define the order of executing child elements defined as List in a POJO.
Suppose we have one Parent class that contains multiple children(Child1 , Child2). The association between parent and child is OneToMany and they are…

Ishani Bhatt
- 1
- 1
0
votes
0 answers
How does the OneToMany annotation with fetch work?
Hibernate newbie here.
So I have a User object with many Opportunity objects:
@Entity
public class User implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long userId;
private String…
user5790716
0
votes
1 answer
org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: Company, for columns: [org.hibernate.mapping.Column(users)]
Hibernate is unable to determine the type for Set at the table Company. I am trying to create a foreign key of table Company through one-to-many relationship. One Company can have multiple users.
Company.java is given below:
@Entity
@Table(name =…

N. A.
- 1
- 3
0
votes
1 answer
Hibernate: joining with one of the keys of a multi-keyed table
I've got a table Category and a table TranslatableText. The category is like this
create table Category (
id int not null,
parent_id int default 0,
TranslatableDescriptionId int default 1,
primary key(id));
create table TranslatableText (
…

niklassaers
- 8,480
- 20
- 99
- 146
0
votes
0 answers
Hibernate onetomany unidirectional relation , deleting mappings when updating Parent object?
I have a Parent class Seller , it have onetomany mappings to all many child classes. It also has some properties as name,id , email . In edit sequence I am fetching this object displays it on jsp , bind it through Spring MVC form , takes input from…

deep mehrotra
- 1
- 3
0
votes
1 answer
Hibernate Unidirectional OneToMany Not Working with composite id
I've been bashing my head on my keyboard for two days trying to figure this out...
Some background: We have a data model set up with a Perl code base that runs straight native SQL statements to the database via ODBC. For certain reasons, we decided…

shaddow
- 405
- 1
- 4
- 19