Posts

Showing posts with the label sql

How liferay is identifying the database configuration

In liferay we configure the database configuration properties in the portal-ext.properties. So when we restart the server or during server startup , we can see the log as  Determine dialect for MYSQL5 or if it is orcale  Determine dialect for oracle 11g . so how liferay is identifying? In Liferay have a look in to the  DialectDetector class and the method  getDialect(DataSource dataSource) . Look into the following code in the method. Connection connection = dataSource.getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); String dbName = databaseMetaData.getDatabaseProductName(); int dbMajorVersion = databaseMetaData.getDatabaseMajorVersion(); dialectKey = dbName.concat(StringPool.COLON).concat( String.valueOf(dbMajorVersion)); dialect = _dialects.get(dialectKey); if (_log.isInfoEnabled()) { _log.info("Determine dialect for " + dbName + " " + dbMajorVersion); } else if (dbName.startsWith("Oracle") &...

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate

Sometimes we have to know SQL query hiting in DB to retrieve the list. Suppose When we are writing the DynamicQuery , Some times we have to know SQL query it is generating to hit DB. So generally it is useful when we are debugging the Query it is generated. In hibernate we used the write the property in XML file as hibernate.show.sql to view the query. In Liferay also we can also set the below property to true in the portal-ext.properties to view the SQL query at the console. hibernate.show_sql=true. By adding the above property it will just reterive the parameters. What if we want to display the parameters. Add the below properties in log4j.properties it will display the paramters also. # logs the SQL statements #log4j.logger.org.hibernate.SQL=debug # Logs the JDBC parameters passed to a query #log4j.logger.org.hibernate.type=trace In Liferay log4j is located in the below location tomcat-7.0.42\webapps\ROOT\WEB-INF\classes Also we want t...