1,053 questions
0
votes
1
answer
56
views
hibernate cant lazy fetch @manyToOne with composite foreign key
this one is a real toughy. I have read a ton of other questions/answers but still cant find an answer. The basic problem is this: When I map a Customer entity in a @ManyToOne association through its ...
1
vote
2
answers
51
views
Django reusable Many-to-one definition in reverse
I'm struggling to make a Many-to-one relationship reusable.
Simplified, let's say I have:
class Car(models.Model):
...
class Wheel(models.Model):
car = models.ForeignKey(Car)
...
Pretty ...
0
votes
1
answer
44
views
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) with @ManyToOne( fetch = FetchType.LAZY ) warn
When I put the TABLE_PER_CLASS inheritance type strategy in the parent class, the tables are generated as expected, however, the same warning appears below, referring to all relationships (@ManyToOne, ...
0
votes
0
answers
16
views
A bidirectional one-to-one association on a foreign key is common with many-to-one issue
[tag:`XML Approach
<class name="Campaign">
<id name="id" column="cmp_num">
</id>
<one-to-one name="person" property-ref="...
1
vote
1
answer
114
views
Spring jpa Hibernate ManyToOne association loading EAGERLY even if FetchType.LAZY
I have a unidirectional ManyToOne relation which is declared as FetchType.lAZY , But when i query using Spring jpa repo (query dsl) findAll() , ManyToOne is eagerly loaded even if DTO layer does not ...
0
votes
1
answer
38
views
Problem with One-To-Many and Many-To-One relations in TypeORM: Incorrect SQL query generated
I'm learning typeORM and I'm stucked with a problem. I've created 3 entities, CategoryTypeAttribute, ItemAttribute and CategoryType.
CategoryTypeAttribute entity:
@Entity('category_type_attribute')
...
0
votes
1
answer
66
views
How to express the reverse of a Many-to-One in Django
I realized that Django has Many-to-One and not One-to-Many, but how to you express the opposite relationship?
I have a table which has 2 foreign keys to another table. The table Validation_Run has 2 ...
2
votes
1
answer
69
views
One to many relationships in Django ORM
I have built several database systems for managing parts databases in small electronics manufacturing setups. I am repeating the process using Django5 and MySQL. I'm a noob with Django but have used ...
0
votes
0
answers
25
views
Bidirectional @OneToMany @ManyToOne with Multi-Tenancy
We are using the Multi-Tenancy in the following structure, where Dog and Cow belong to different schema and NEVER co-exist in the same schema:
Parent Class, which is in both schema HOME and FARM:
@...
0
votes
1
answer
59
views
Error with @ManyToOne @OneToMany declarations
Hi, I am starting with a project with TypeScript, TypeORM and Postgres. I made the entities that seems to be correct but I got some errors I do not understand. The problem found is between a ...
0
votes
1
answer
75
views
@manytoone jpa save problem - duplicate entry
Scenario:
Suppose I have a springboot jpa app:
public class Home {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long homeId;
@ManyToOne(cascade = CascadeType.ALL)
...
1
vote
0
answers
130
views
SwiftData many-to-one relationships not being created until app restart
I'm trying to create a data structure in SwiftData that uses a many-to-one relationship, however, the parents list of children is not being appended to until the app is restarted.
I've modified the ...
1
vote
1
answer
32
views
How to query many-to-one using @Relation in Android Room
If a user can only be in one group, then user:group is a many-to-one relation.
@Entity(tableName="user")
data class UserEntity(
@PrimaryKey(autoGenerate = true)
val uid: Int,
val ...
0
votes
1
answer
24
views
Renaming relational tables on existing schema in Django
Due to a migration from django 2.x to django 4.x, I had to rename my project to fix the intial name containing '-' and no '_'.
The initial project name was DEMANDE-PROJET
In a Model called DEMANDE ( ...
0
votes
1
answer
28
views
EF fails when Inserting only one out of two properties of the same type
I have this closure table that is supposed to make easier to get all replies of a comment, their replies, all replies to the comment ( even distant inheritants), but when I try to insert the parent - ...
0
votes
0
answers
57
views
Issue with Lazy loading OneToMany Hibernate - Java
I'm studying Spring and Hibernate and for my test I have this these classes (tables) with oneToMany and ManyToOne relationships:
@Entity
@Table(name = "photo")
public class Photo {
@Id
...
0
votes
0
answers
36
views
JPA composite key class for join table containing object references vs only containing ids
I'm trying to set up a join table to map a set of items to groups (in a many-to-many relationship) that can also have extra columns in addition to the object ids. I'm trying to use the object ids to ...
0
votes
0
answers
25
views
Is there a way to fetch Associated Entity from second level Cache instead of hitting the DB in Hibernate?
Suppose I have two entities : StudentDO and ParamDO. ParamDO is an entity that contains parameter code & values that are used throughout the application.
I have already cached this entity using ...
0
votes
0
answers
14
views
How to establish a two-way one-to-many relationship between a composite restriction of fields?
How to establish a two-way one-to-many relationship between a composite restriction of fields from a composite primary key in hibernate?
Hi friends, help me solve the problem. There is a table one and ...
-1
votes
1
answer
45
views
Hibernate @ManyToOne Cascade working super weirdly
I have a project where every Student can be tested by a Tester, and a single tester can test many students.
I need students to know their testers - so this is a unidirectional Many to One.
Tester:
@...
0
votes
1
answer
59
views
How can gracefully omit existent ManyToOne relationship?
I have legacy code with lots of relationships in one entity in Hibernate.
Currently part of them are not using(there are null values for them in DB), but EntityManager query such as refresh() can ...
0
votes
0
answers
22
views
Remove orphans with JPA/Hibernate in opposite direction
I'm struggling with this problem:
It is quite difficult in JPA/Hibernate to remove an orphaned child from multiple parents.
When the relation is: multiple-parent > multiple-children there is no ...
0
votes
0
answers
28
views
Three dimensional relations in NestJS
I have three entities: User, Meal, Date.
Date:
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToMany,
JoinTable,
} from 'typeorm';
import { User } from '../../users/entities/user....
0
votes
0
answers
193
views
OutOfMemoryError: Java heap space with @ManyToOne(fetch = FetchType.EAGER) after Migrating to spring boot 3.2;Hibernate 6.3
if I set @ManyToOne(fetch = FetchType.LAZY) it is working. In my case I need EAGER loading. But this leads to the OutOfMemoryError. Even if they increase the in maven memory, it does not work:
<...
0
votes
0
answers
45
views
Groupby at least one match between two columns with Pandas only(not Networkx library) [duplicate]
I have a table.
+------+---------------+
| id | co_id |
+------+---------------+
| 123 | abc |
| 123 | bcd |
| 234 |abc |
| 123 |def |
| ...
0
votes
0
answers
37
views
How to manage concretely with unamangeable model relationship in Power BI
I was asked to use two sources of data sharing the same column and build both a many-to-one and one-to-one relationship with PowerBI. It is not possible to modelize any of two relationship and ...
1
vote
1
answer
70
views
OneToMany relationship doesn't save id of owner entity in secondary entity
Im trying to save in postgres 2 entities, Configuration and Screen. Configuration can have many Screens, then is oneToMany, and one Screen can have one Configuration, then ismanyToOne. I'm using JPA ...
0
votes
1
answer
880
views
NestJs create relation given the id
I have 2 entities: User and Article. One article is created by one user, but one user may create many articles. Their respective entities are defined like this:
export class Article {
id?: string; ...
-1
votes
1
answer
56
views
cant understand @joincolumn(name="user_id")
i have created two seperated class in entity,
varibale declared in user class is :
private Long id;
private String name;
variable declared in book class is:
private Long id;
private String title;
...
0
votes
1
answer
158
views
With NestJS and TypeORM, can I get away with passing an ID to a @ManyToOne relation?
I'm using NestJS 10 and typeorm 0.3.17. I hvae this entity ...
@Entity()
export class Card {
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToOne(type => User)
@JoinColumn({...
1
vote
1
answer
473
views
Can not set field value by reflection error - hibernate proxy object
I am having real trouble with trying to initialize a proxy hibernate object.
This is the error i am getting:
Can not set com.application.network.domain.MeteredPoint field com.application.network....
1
vote
0
answers
67
views
Hibernate, many-to-one not-found="ignore", Criteria add Restrictions, list,- could not resolve property
My table has links pointing to non-existent records. To extract an object with a broken link, I used not-found="ignore":
<class name="pattern" table="PATTERN">
...
1
vote
1
answer
2k
views
How to save only a child entity and populate the parentId in the table Using save operation on the child entity
I would like to understand this basic concept. How do we save the child entity and populate the foreign Key ID in the Child table. I have this situation where Parent Can have many child. But the Child ...
0
votes
1
answer
127
views
Search in many2one field odoo
In Odoo 15, Sale order view, inside the sale order line.. we can search a product by barcode, but i want to make the search case insensitive so for example if i have two product one having barcode ='...
0
votes
0
answers
87
views
java - Spring Boot JPA - Wrong JOIN by JPA
I'm trying to create an association between two tables such as :
Representation can have multiple Bookings,
Booking can only have a single Representation
I was trying to use the Javax persistence @...
0
votes
1
answer
53
views
hibernate Same table @manytoone reference in @embeddedid
I am trying to create an entity which is called Category. Categories are multi-level for Example:
I can have a category with name food which is the top level. Then I can have 2 more categories under ...
1
vote
1
answer
784
views
Using transient objects to specify ids for saving ManyToOne relations
I want to save a lot of Spring JPA entities by importing them in batches to the database.
Some entities have ManyToOne relations to other Entities.
As there is a large amount of data, I'd prefer not ...
0
votes
1
answer
30
views
Specification<T> used for filtering join table with relationship @ManyToOne
!(https://i.sstatic.net/p5Tjt.png)
{
"country_code":["IT", "FR", "EG"]
}
In this way I can filter all cities for specific country_code
here ...
0
votes
0
answers
188
views
In a @OneToMany and @ManyToOne relationship, how to set a property for the "many" entity when the other null and they is mapped by that property
I have a @OneToMany relationship: one team - many students. The Team entity use @EmbeddedId to define the main key with two column "teamId" and "classId" so when mapping with ...
0
votes
0
answers
98
views
SQLAlchemy one-to-many relationship between subclasses
I have a problem defining a one-to-many relationship between two subclasses in SQLAlchemy. I have a base class called CompanyModel. From it I inherit two classes: BusinessUnitModel and ClientModel. I ...
3
votes
3
answers
79
views
How to assign an order to field in a many to many field
This is my first django project so I'm still learning. I Django project of Formula One Races and Racers. The Race model looks like this,
class Race(models.Model):
name = models.CharField(...
1
vote
0
answers
133
views
@ManyToOne(fetch = FetchType.LAZY) annotation makes extra queries
I have two entities
The first:
@Entity
data class EntityA(
...
@ManyToOne(fetch = FetchType.LAZY)
var entityB: EntityB,
...
)
The second one:
@Entity
data class EntityB(
...
)
...
0
votes
1
answer
271
views
Change the relationship from @ManyToOne to @OneToOne
Is there a need to change the relationship from @ManyToOne to @OneToOne?
I mistakenly defined relation @ManyToOne instead of relation @OneToOne in my code
My classes in brief :
Class dev:
.
.
private ...
1
vote
1
answer
37
views
Id Commande not populated on table Lignes Comandes
I tried to implement a method to add new commande so i create i entity Commande and Ligne Commande as below :
Commande Entity:
import java.util.Date;
import java.util.List;
import javax....
1
vote
1
answer
69
views
Embed a many to one Room DAO object with multiple occurence of single entry in two different spots in the data hiearachy
I have the following datastructure
Jobs includes a list of Workers and a list of Posters
Posters have a single worker.
I am able to get the list of workers and posters embedded into the Job object; ...
2
votes
1
answer
364
views
How to Add a field in cascade of 2 many to one on Easyadmin 4 Symfony 6
I read and try a lots of things just to add a field witch is in relation.
One Dance have a level (beginner, improver...) and one Level have a Style (Country music, disco...). So for a dance I can get ...
2
votes
0
answers
74
views
Postgres Left Join ignores row if ManyToOne property is null
In Spring Boot i have the following query in a PostgreSQL database, to get data from ConfigElement table and set them to the new one ConfigurationReview table. It works properly as expected:
@Query(
...
0
votes
0
answers
32
views
SqlAlchemy doubly linked tables [duplicate]
I have the following tables declared:
uuidpk = Annotated[UUID, mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)]
user_fk = Annotated[UUID, mapped_column(UUID(as_uuid=True), ...
0
votes
0
answers
60
views
JPA - Does @OneToMany demand @ManyToOne?
I am developing an application with JPA and I came across a small problem.
I have this two entities Category and Supplier.
A Supplier must have at least one category so I used the @OneToMany tag.
@...
0
votes
2
answers
305
views
Hibernate OneToMany ManyToOne on delete cascade
I'm trying to use Hibernate to map the following relationship:
Each order contains 2 images. When I delete an order I want the images gone as well.
I have two entities, OrderItems and Image and they ...