Questions tagged [hibernate-onetomany]

Questions regarding the implementation of one to many relations using Hibernate ORM framework

281 questions
0
votes
1 answer

Persisting Child entity when using mappedBy in Hibernate

My DB schema has two tables :- Rule Table and Rule Scope table. Rule Table columns (rule_id Primary Key, .....) and Rule Scope columns (rule_id Foreign key , Scope_id (NOT Auto generated Id, Can repeat for different rule_id) Rule Scope Primary key…
Art
  • 414
  • 7
  • 24
0
votes
1 answer

OneToMany Hibernate Save Cascade Problems

I was working with Hibernate and OneToMany Relationship, i came across a weird behavior today , although i did it purposely but i was not expecting this behavior College.java @Entity @Table(name="COLLEGE") public class College implements…
Digital Alchemist
  • 2,324
  • 1
  • 15
  • 17
0
votes
1 answer

Hibernate mapping, on a unmapped class

I' ve got 2 tables... Challenge and ChallengeYear, ChallengeYear is only to create a list of years in challenge. I only want to make Challenge an entity, containing a list of List years. Is this possible? I've looked in to @SecondaryTable together…
Jan
  • 3
  • 1
0
votes
1 answer

hibernate Mapping One to many relation ship between primary key and composite key

I am struggling with a hibernate mapping problem of mapping One to many relation ship between Primary key of Order Table and composite key of Product Cart with some extra columns public class OrderDetails implements Serializable { /** * …
Salim
  • 714
  • 1
  • 5
  • 19
0
votes
1 answer

Hibernate/Jpa OneToMany not retrieving data properly

I have an entity class named User which contains this OneToMany column for database: @Setter @OneToMany(cascade = CascadeType.ALL, mappedBy = "user") @JoinTable( name = "USER_CARS", joinColumns = @JoinColumn(name="USER_ID",…
smotru
  • 433
  • 2
  • 8
  • 24
0
votes
0 answers

Hibernate ManyToOne - OneToMany loop?

i'm new to hibernate and i use annotations These are my two tables: This is my Table "Persona" @Entity @Table(name = "persona") public class Persona implements java.io.Serializable { @Id @GeneratedValue(strategy =…
0
votes
1 answer

Saving OneToMany relation with id generated by trigger

I Have two DTOs: @Entity @Table( name = "USER" ) public class UserDto implements Serializable { @Id @GeneratedValue( generator = "trigger_gen" ) @GenericGenerator( name = "trigger_gen", strategy = "path.TriggerAssignedIdentityGenerator"…
dzuma
  • 171
  • 5
  • 17
0
votes
1 answer

Hibernate OneToMany relationship with a not concrete class

There is a way to use a interface as OneToMany relationship using Hibernate? I mean I have a class Document and it has a column List to me to get all records. For each MyInterface I need to have a different concrete class.
SaXeTz
  • 500
  • 1
  • 3
  • 14
0
votes
1 answer

Bidirectional mapping in hibernate

I have two tables, quotation and quotation_item. There is one to many relationship them. My requirement is when I do quotation.setQuotationItem(set), old quotationItem mapped to quotation should get removed and quotationItems in set should get…
Bhushan
  • 1,489
  • 3
  • 27
  • 45
0
votes
0 answers

DB Unit TypeCastException

I'm trying to setup unit tests for my simple application, but when setting up my test data, I always get a TypeCast error. Here the needed info: 1) Database schema: USE [EDIKANBAN] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET…
0
votes
1 answer

Hibernate 3 cascade all not deleting existing record

I have 3 classes A, B and C. And there relationships are: One to many bi-directional from A to B. C extends B. I am able to add new records and edit existing records of address collection, but i am not able to remove any existing record. Code to…
Atul
  • 1,536
  • 3
  • 21
  • 37
0
votes
2 answers

Adding NULL in database

I am new to hibernate. I have two classes UserDetails and Address.The relation between these two is One-To-Many.The details are as follows(Skiping getter and setters) UserDetails.java @Entity @Table(name = "UserDetails") public class UserDetails { …
Niks
  • 885
  • 1
  • 7
  • 17
0
votes
1 answer

Delete a record from Parent Table in one-to-many relationship in hibernate

I have the following situation: One table of Customers can have many projects. the relationship is bidirectional. I am trying to delete a customer from a list of Customers and if the customers has already assigned with some projects I got an…
0
votes
3 answers

Can not delete an instance of OneToMany relationship in hibernate

I have a OneToMany relationship, I can insert records but can not delete them, when I try to delete it runs into " a foreign key constraint fails" error. I have used cascade delete orphan as following but does not work yet. Parent class has…
Tim Norman
  • 421
  • 1
  • 12
  • 31
0
votes
1 answer

Hibernate OneToMany and ManyToOne?

In Hibernate, you can specify a one-to-many or it's inverse many-to-one via @OneToMany or @ManyToOne annotations, respectively. But in the examples I see, every time you relate A to B, you need to also relate B to A. For instance, if Teacher has a…
user1768830