Caucho maker of Resin Server | Application Server (Java EE Certified) and Web Server


Resin Documentation

Aug 2012: Resin outscales C-based web server nginx in AutoBench benchmark
Feb 2012: NetCraft survey says Resin experiencing strong growth in last year and used in number of the Million Busiest Sites.
home company blog wiki docs 
app server web server 
health cloud java ee pro 
 Resin Server | Application Server (Java EE Certified) and Web Server

query cmp

The Amber Query API resembles the JDBC PreparedStatement with enhanced SQL and direct support for objects.


Files in this tutorial

WEB-INF/resin-web.xmlresin-web.xml configuration
WEB-INF/classes/META-INF/persistence.xmlpersistence.xml configuration
WEB-INF/classes/example/Student.javaThe student bean
WEB-INF/classes/example/House.javaThe house bean
WEB-INF/classes/example/QueryServlet.javaThe course servlet

Database Schema
public class House {
  public long getId()

  public String getName()

  public Collection getStudentList()
public class Student {
  public long getId()

  public String getName()

  public House getHouse()

  private void doService(PrintWriter out)
    Query allHouse = _entityManager.createQuery("SELECT o FROM House o");
    String sql = ("SELECT s" +
		  " FROM House h, IN(h.studentList) s" +
		  " WHERE AND s.gender='M'");
    Query boysInHouse = _entityManager.createQuery(sql);
    List houses = allHouse.getResultList();

    for (int i = 0; i < houses.size(); i++) {
      House house = (House) houses.get(i);
      out.println("<H3>Boys living in " + house.getName() + ":</H3>");

      boysInHouse.setParameter(1, new Long(house.getId()));
      List boys = boysInHouse.getResultList();

      if (boys.size() == 0)
	out.println("No boys are living in " + house.getName());

      for (int j = 0; j < boys.size(); j++) {
	Student boy = (Student) boys.get(j);

	out.println(boy.getName() + "<br>");


Copyright © 1998-2012 Caucho Technology, Inc. All rights reserved. Resin ® is a registered trademark. Quercustm, and Hessiantm are trademarks of Caucho Technology.