chaitu chaitu
asked on
how to restrict to specific columns of both tables data when joining two tables in hibernate
i am joining two tables and fetching data from both tables.
String hql = "from Supplier s inner join fetch s.products as p";
Query query = session.createQuery(hql);
it will execute below query;
select supplier0_.id as id1_0_, products1_.id as id0_1_, supplier0_.name as name1_0_, products1_.name as name0_1_, products1_.description as descript3_0_1_, products1_.price as price0_1_, products1_.supplierId as supplierId0__, products1_.id as id0__ from Supplier supplier0_ inner join Products products1_ on supplier0_.id=products1_.s upplierId
if i have 50 columns in Supplier and 100 columns in Products table then all those columns will come in this query;i want only specific columns say 10 columns from both of these tables supplier and products then how will u reqrite this query?
String hql = "from Supplier s inner join fetch s.products as p";
Query query = session.createQuery(hql);
it will execute below query;
select supplier0_.id as id1_0_, products1_.id as id0_1_, supplier0_.name as name1_0_, products1_.name as name0_1_, products1_.description as descript3_0_1_, products1_.price as price0_1_, products1_.supplierId as supplierId0__, products1_.id as id0__ from Supplier supplier0_ inner join Products products1_ on supplier0_.id=products1_.s
if i have 50 columns in Supplier and 100 columns in Products table then all those columns will come in this query;i want only specific columns say 10 columns from both of these tables supplier and products then how will u reqrite this query?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.