Skip to content

Create child entity without having full parent entity (Postgres) #5523

Answered by B4nan
vladkrasn asked this question in Q&A
Discussion options

You must be logged in to vote

It complains that User.name wasn't provided

You mean some runtime validation? Can you share the full error with a stack trace? I checked the tests and found a very similar test that works just fine. Maybe provide a complete reproduction so its clear what you are doing.

I would generally discourage using mapToPk, as you will lose a lot of features the ORM provides. Note that you can create an entity instance from its PK without loading it with em.getReference() (and this works natively in em.create and em.assign, just pass a FK value in place of a relation and the EM will create em.getReference automatically for you), so if that was the reason why you tried to use it, it's not really a r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vladkrasn
Comment options

Answer selected by vladkrasn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants