Skip to content

Simple one to one relationship (one way) should work  #988

@gauravpolekar

Description

@gauravpolekar

In normal case we have one to one parent child relationships.
Like one parent class User and it has a child UserType.

@Data public class User { @Id private Long id; private String name; private UserType type; } @Data public class UserType { @Id private Long id; private String type; } 

Having schema as :

Table User:
Column : id (Primary key), name , user_type_id foreign key to UserType.id column

Table UserType
Column : id (Primary key), name

User type is master table, whenever we need to add user, based on type we select and create user.

This should work normally with UserRepository<User, Long>.

But when we use this schema and classes, it generates wrong query as it accepts User.id should be present in UserType table.

Which is wrong as this is master table, I dont want it to grow when new user added.

similar question on Stack overflow

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions