Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Thursday, April 29, 2010

Insert for multiple records


insert into ce_antennaSocket(platformName, socketID, socketName, radioBandID) values
('AP2600', '0', 'Left Antenna Type', 0),
('AP2600', '1', 'Right Antenna Type', 0),
('AP2650', '0', 'Top Left Antenna Type', 0),
('AP2650', '1', 'Bottom Left Antenna Type', 0),
('AP2650', '2', 'Top Right Antenna Type', 0),
('AP4102', '1', 'Right Antenna Type', 1);

It has much much better performance than split into multiple insert statements. To insert 15k records, it took less than 1 second. Otherwise, it took 8 minutes.

Monday, March 15, 2010

Hibernate Native SQL

Hiberante HQL/Criteria doesn't support the query for Map collection with dereferenced key object. AddEntity() method will convert the result into domain object, otherwise, it would be an object array.


String sqlStr = "select t.* from ce_template t, ce_apProfileTemplate_wlanServiceTemplate aw "
+ "where t.id=aw.apProfileTemplateId and t.templateType='APPROFILE' and t.oldId=0 "
+ "and aw.wlanServiceTemplateId=:id";
Query query = getSession().createSQLQuery(sqlStr)
.addEntity("t", Template.class)
.setInteger("id", t.getId());

Tuesday, February 12, 2008

MySQL sql udpate - multiple table syntax


update polleddata pd set pd.absolutelastcountervalue=
( select lastcountervalue
from v2r2_temp_tbl1 vtt
where vtt.id=pd.id);

will run 15 minutes for 8000+ records. Change it to:

update polleddata pd, v2r2_temp_tbl1 vtt
set pd.absolutelastcountervalue=vtt.lastcountervalue
where pd.id=vtt.id;

has much better performance.