thanks for the replies. one of the salient features of hibernate is that the usage of the api is simple to follow. and this not a complex test case that can deviate too much from the usual usage model. so before the benchmarking is dismissed completely, i've included the code that produced these results. comments?
(brenuart, also i've taken the object creation time into account while working with JDBC)
JDBC code for find by id
Code:
Statement stmt = conn.createStatement();
ResultSet resultSet = stmt.executeQuery("select * from device where id= '" + id + "'");
if(!resultSet.next()) System.err.println("Could not find device by id");
Device device;
device = new Device();
device.setAdminInterfaceIP(resultSet.getString("administrative_interface_ip"));
device.setBackupStatus(resultSet.getString("backup_status"));
device.setCreationState(resultSet.getString("creation_state"));
device.setStatus(resultSet.getString("device_status"));
device.setBackupEnabled(resultSet.getBoolean("backup_enabled"));
stmt.close();
hibernate query by id
Code:
Configuration cfg = new Configuration()
.addClass(Device.class)
.addClass(History.class)
.setProperty(Environment.HBM2DDL_AUTO, "create")
.setProperty(Environment.DIALECT, "net.sf.hibernate.dialect.MySQLDialect")
.setProperty(Environment.DRIVER, "org.gjt.mm.mysql.Driver")
.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver")
.setProperty(Environment.URL, "jdbc:mysql:///test")
.setProperty(Environment.USER, "")
.setProperty(Environment.PASS, "");
.
.
.
private void alterpointGetSingleDeviceById(int id)
{
try
{
Long i = new Long(id);
List list = s.find("from Device as device where device.ID =" + i);
if (list.size()==0) throw new IllegalArgumentException("No device for the given id: " + id);
Device device = (Device) list.get(0);
}
catch (Exception e) {
e.printStackTrace();
}
}
the times are all in ms. and the factory initilization is surely not included.
R