- ext/ext-impl/classes/custom-sql/${portlet}.xml
- ext/ext-impl/src/com/mpower/queryutil/${portlet}.ApiHelper.java
- extext-impl/classes/custom-sql/default.xml
Step 2) Find the XML files for the queries of the desired portelt
AddressBook.xmlAddressbookApiHelper.java
package com.mpower.queryutil;
import com.liferay.portal.SystemException;
import com.liferay.portal.spring.hibernate.CustomSQLUtil;
import com.liferay.portal.spring.hibernate.HibernateUtil;
import com.liferay.portlet.service.BasePersistence;
import com.mpower.common.addressbook.model.Address;
import com.mpower.common.addressbook.model.impl.AddressImpl;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import java.math.BigInteger;
import java.util.List;
public class AddressbookApiHelper extends BasePersistence {
public static String GET_RECORD_COUNT = Address.class.getName() +
".getRecordCount";
public static long getRecordCount() throws SystemException {
Session session = null;
try {
long count = 0;
session = HibernateUtil.openSession();
String sql = CustomSQLUtil.get(GET_RECORD_COUNT);
SQLQuery q = session.createSQLQuery(sql);
q.setCacheable(false);
List list = q.list();
if (list != null) {
BigInteger bint = (BigInteger) list.get(0);
count = Long.parseLong(bint.toString());
}
return count;
} catch (Exception e) {
throw new SystemException(e);
}
}
}
package com.mpower.queryutil;
import com.liferay.portal.SystemException;
import com.liferay.portal.spring.hibernate.CustomSQLUtil;
import com.liferay.portal.spring.hibernate.HibernateUtil;
import com.liferay.portlet.service.BasePersistence;
import com.mpower.common.addressbook.model.Address;
import com.mpower.common.addressbook.model.impl.AddressImpl;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import java.math.BigInteger;
import java.util.List;
public class AddressbookApiHelper extends BasePersistence {
public static String GET_RECORD_COUNT = Address.class.getName() +
".getRecordCount";
public static long getRecordCount() throws SystemException {
Session session = null;
try {
long count = 0;
session = HibernateUtil.openSession();
String sql = CustomSQLUtil.get(GET_RECORD_COUNT);
SQLQuery q = session.createSQLQuery(sql);
q.setCacheable(false);
List list = q.list();
if (list != null) {
BigInteger bint = (BigInteger) list.get(0);
count = Long.parseLong(bint.toString());
}
return count;
} catch (Exception e) {
throw new SystemException(e);
}
}
}
Default.xml
If you are Connecting to Another Datasource/Database. Need two extra steps:
- Go to ext-spring-training.xml and get the id trainingSessionFactory or what you name it.
- Whith this id, open a new hibernate session on the code above, refering to the another database, like this:
//open a new session
session = HibernateUtil.openSession(&trainingSessionFactory);
1 comment:
SAYA IBU YENI,NURLINA INGIN BERBAGI CERITA KEPADA ANDA BAHWA SAYA INI DULUNYA ORANG YANG PALING SENSARA DIDUNIA.SETIAP HARI ISTRI SAYA SELALU MENGELUH TENTAN MASALAH EKONOMI BAHKAN KAMI PERNAH TIDAK MAKAN DALAM 1 HARIL 1 MALAM,KE ESOKAN HARINYA ADA TETANGNGA KAMI YG MEMBAWAKAN MAKANAN DAN TIDAK DISENGAJA DIA JG BERCERITA TENTAN MASALAH HIDUPNYA DULU DAN AKHIRNYA DIA MEMBERIKAN NO MBAH RORO..TIDAK BERPIKIR PANJAN SY LANSUN MENGHUBUNGI MBAH RORO DAN ALHAMDULILLAH BELIAU SANGAT MEMBANTU SAYA DAN SY SANGAT BER TERIMAKASIH KEPADA MBAH RORO ATAS BANTUANNYA YG TELAH MEMBERIKAN ANKA JITUNYA YAITU (6319) SYUKUR ALHAMDULILLAH BERHASIL DAN KINI SAYA SANGAT BAHAGIA MELIHAT KEHIDUPAN KELUARGA SAYA YG SUDAH JAUH LEBIH BAIK DARI SEBELUMNYA DAN MEREKA JUGA TDK PERNAH LAGI MENGELUH MASALAH KEUWANGN,,KAMI JG SUDAH BERENCANA INGIN MEMBUKA TOKO SENDIRI ITU SEMUA BERKAT BANTUAN MBAH RORO DAN BAGI ANDA YG INGIN SEPERTI SAYA YG MEMERLUKAN BANTUAN MBAH RORO SILAHKAN HUB 0-8-5-3-9-4-5-3-7-5-7-8 SILAHKAN ANDA MEMBUKTIKANNYA SENDIRI.????MAKASIH….http://wwwprediksimbahjenggo.webs.com
PREDIKSI TOGEL SINGAPURA KAMIS HARI INI
SGP KAMIS 06-Fec-2014
=================
** ANGKA KONTROL **
5435
** ANGKA IKUT **
1247
** SYAIR SGP KAMIS **
DISINI
AWASS,,!! SERING NYEBUR DILUMPUR LAPINDO
??????
Post a Comment