Dúvida Criteria

Asked

Viewed 37 times

1

I can do a criteria with an entity that is not mapped in another entity? Or I have to use native query to do this query?

I have a user entity and another product but I have no product relationship with user but I have to bring the name of the user in the product query and in the user there is only one idProduct variable without relationship.

Example:

   @Entity
    @Table(name = "DCF_USUARIOS")
    public class UsuarioTO{


            @Id
            @Column(name = "id")
            @GeneratedValue(strategy = GenerationType.AUTO)
            private Long id;

         @Column(name = "nome_usuario")
            private String nomeUsuario;


            @Column(name = "id_produto")
            private Long idProduto;
        }

        @Entity
        @Table(name = "DCF_PRODUTO")
        public class ProdutoTO{


            @Id
            @Column(name = "id")
            @GeneratedValue(strategy = GenerationType.AUTO)
            private Long  id;

        }

So I want to make a product criteria, but I need to bring the name of the user who has the product id recorded in the entity and who are not related to each other. Would it be wise or I have to do a native Join between the two tables?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.