Is there an entity's way of belonging to a user in hibernate

1

I'm looking for a simplified way of linking a bank entity to a specific user, who has registered, so that you do not need to set the field at the time of registration. Is there any simplified way to do this?

The biggest problem of putting a foreign key is that you then need to rewrite the querys so that the query takes the user logged in.

Example:

@Query(value = "SELECT * FROM produto where p.userid = ?1",
            countQuery = "SELECT count(*) FROM produto")
Page<Produto> findAll(long userid, Pageable pageable);

What makes it difficult to work because for each new entity that I need to rewrite it.

    
asked by anonymous 13.12.2017 / 23:31

0 answers