Session session=s1.openSession();
//select os.osname id.name from machine id, osvo so
Criteria criteria = session.createCriteria(osvo.class, "os");
criteria.createAlias("os.machineid", "id", Criteria.INNER_JOIN);
ProjectionList p=Projections.projectionList();
p.add(Projections.property("id.name"));
p.add(Projections.property("osname"));
criteria.setProjection(p);
List l1 = criteria.list();
Gson gson = new Gson();
String record = gson.toJson(l1);
System.out.println("record in json = " + record);