LegacyDAO

Manage the execution of queries in database. For example, the execution of queries in SQL or HQL. 

Methods

executeSQL

Description:

MethodReturn valuesDescription

executeSQL(final String query)

List<List<String>>

Execute SQL query.

query: The text of the query to execut

Example:

package com.openkm;

import java.util.List;

import com.openkm.bean.form.Option;
import com.openkm.dao.LegacyDAO;

public class Test {
	public static void main(String[] args) {
		try {
			String query = "select DMT_VIRTUAL_COLUMN, DMT_REAL_COLUMN from OKM_DB_METADATA_TYPE";
			for (List<String> row : LegacyDAO.executeSQL(query)) {
				Option option = new Option();
				option.setValue(row.get(0));
				option.setLabel(row.get(1));
				System.out.println("First value :" + row.get(0) + " Second value: " + row.get(1) + " ...");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

executeHQL

Description:

MethodReturn valuesDescription

executeHQL(final String query)

List<object>

Execute HQL query.

query: The text of the query to execut

Example:

package com.openkm;

import java.util.List;

import com.openkm.dao.LegacyDAO;

public class Test {
	public static void main(String[] args) {
		try {
			String query = "select dmt.virtualColumn, dmt.realColumn from DatabaseMetadataType dmt";
			List<object> list = LegacyDAO.executeHQL(query);
			for (Object obj : list) {
				Object[] dt = (Object[]) obj;
				System.out.println(
						"First value :" + String.valueOf(dt[0]) + " Second value: " + String.valueOf(dt[1]) + " ...");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}