I have just downloaded openunderwriter insurance solution with source code and set it up to open in and run from Eclipse. The project is uses Liferay framework and it also uses Hibernate for data persistence in MySQL database. I want to somehow enable debugging of SQL queries that are sent to MySQL server from Hibernate whenever I perform a CRUD operation in the application.
I have found many similar questions on SO and elsewhere like this, this and this to mention a few. I tried to follow them but could not get the queries to be printed on console. One problem is that there are more than 15 log4j.properties
files in the project. I have updated all of them with the relevant properties but to no avail so far. I am new to Hibernate and don't know a thing about Liferay framework. How can I enable the SQL debugging in openunderwriter?
Edit: I have setup openunderwriter by cloning it from bitbucket repository and following the setup instructions to open it in Eclipse. It uses Ant builds. I can successfully start/stop/build it using Ant commands from Eclipse and use the application from browser. I could not find [OPEN_UNDERWRITER_HOME]/liferay-portal-6.2.0-ce-ga1
directory in the repository. However, I did find
[OpenUnderWriterHome]\system\target\liferay-portal-6.2-ce-ga6\
directory. And I made changes to the log4j.properties
file in the following directory assuming that *g1
and '*g6` indicates the version difference
D:\OpenUnderWriter\OpenUnderWriterRepo\system\target\liferay-portal-6.2-ce-ga6\jboss-7.1.1\standalone\deployments\ROOT.war\WEB-INF\classes
The contents of log4j.properties
file in above directory are as follows
log4j.rootLogger=INFO, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n
log4j.logger.org.hibernate.SQL=debug
log4j.logger.org.hibernate.type=trace
log4j.logger.org.hibernate.jdbc=DEBUG
log4j.logger.org.hibernate.transaction=DEBUG
But when I go to the logs files in D:\OpenUnderWriter\OpenUnderWriterRepo\system\target\liferay-portal-6.2-ce-ga6\logs
, there are no sql queries and no parameter values. However, Eclipse console does show the sql queries but it shows them with ?
marks instead of parameter values. And even the showing of queries is due to show_sql=true
property set in HibernateConfiguration.xml
file. If I remove this property and rebuild the code, the queries stop showing in console as well. Is there something wrong I am doing?
Edit 2:
I have two HibernateConfiguration.xml
files. The first one is at D:\OpenUnderWriter\OpenUnderWriterRepo\system\target\test\integration-test.jar\com\ail\core\persistence\hibernate
and the second one is at D:\OpenUnderWriter\OpenUnderWriterRepo\system\modules\com\ail\core.jar\com\ail\core\persistence\hibernate
. The contents of the both files respectively are as under
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="org.hibernate.envers.track_entities_changed_in_revision">true</property>
<property name="org.hibernate.envers.audit_table_suffix">_</property>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://@dbhost@:3306/@dbname.openunderwriter@</property>
<property name="connection.username">@dbusername@</property>
<property name="connection.password">@dbpassword@</property>
<property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.bytecode.use_reflection_optimizer">true</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- Mappings for all classes come from one place -->
<mapping class="com.ail.core.Attribute" />
<mapping class="com.ail.core.ForeignSystemReference" />
<mapping class="com.ail.core.Note" />
<mapping class="com.ail.core.Reference" />
<mapping class="com.ail.core.PageVisit" />
<mapping class="com.ail.core.Type" />
<mapping class="com.ail.core.Version" />
<mapping class="com.ail.core.audit.envers.Revision" />
<mapping class="com.ail.core.document.Document" />
<mapping class="com.ail.core.document.DocumentContent" />
<mapping class="com.ail.core.document.DocumentPlaceholder" />
<mapping class="com.ail.core.document.DocumentRequest" />
<mapping class="com.ail.core.key.UniqueKey" />
<mapping class="com.ail.core.logging.ServiceRequestRecord" />
<mapping class="com.ail.core.product.ProductChangeEvent" />
<mapping class="com.ail.core.product.ProductUpgradeLog" />
<mapping class="com.ail.financial.CurrencyAmount" />
<mapping class="com.ail.financial.DirectDebit" />
<mapping class="com.ail.financial.Eway" />
<mapping class="com.ail.financial.IWinPay" />
<mapping class="com.ail.financial.MoneyProvision" />
<mapping class="com.ail.financial.Orange" />
<mapping class="com.ail.financial.PaymentCard" />
<mapping class="com.ail.financial.PaymentHoliday" />
<mapping class="com.ail.financial.PaymentMethod" />
<mapping class="com.ail.financial.PaymentRecord" />
<mapping class="com.ail.financial.PaymentSchedule" />
<mapping class="com.ail.financial.PayPal" />
<mapping class="com.ail.financial.SagePay" />
<mapping class="com.ail.financial.Stripe" />
<mapping class="com.ail.financial.ledger.Account" />
<mapping class="com.ail.financial.ledger.AccountingPeriod" />
<mapping class="com.ail.financial.ledger.Balance" />
<mapping class="com.ail.financial.ledger.Journal" />
<mapping class="com.ail.financial.ledger.JournalLine" />
<mapping class="com.ail.financial.ledger.Ledger" />
<mapping class="com.ail.insurance.claim.Claim" />
<mapping class="com.ail.insurance.claim.ClaimRecovery" />
<mapping class="com.ail.insurance.claim.ClaimSection" />
<mapping class="com.ail.insurance.policy.AssessmentSheet" />
<mapping class="com.ail.insurance.policy.Asset" />
<mapping class="com.ail.insurance.policy.Broker" />
<mapping class="com.ail.insurance.policy.Clause" />
<mapping class="com.ail.insurance.policy.CommercialProposer" />
<mapping class="com.ail.insurance.policy.Coverage" />
<mapping class="com.ail.insurance.policy.PersonalProposer" />
<mapping class="com.ail.insurance.policy.Policy" />
<mapping class="com.ail.insurance.policy.Section" />
<mapping class="com.ail.party.Address" />
<mapping class="com.ail.party.ContactSystem" />
<mapping class="com.ail.party.EmailAddress" />
<mapping class="com.ail.party.Party" />
<mapping class="com.ail.party.PartyRelationship" />
<mapping class="com.ail.party.PartyRole" />
<mapping class="com.ail.party.Person" />
<mapping class="com.ail.party.PhoneNumber" />
<mapping class="com.ail.party.Organisation" />
<mapping class="com.ail.util.DateOfBirth" />
</session-factory>
</hibernate-configuration>
and the second HibernateConfiguration.xml
is
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="org.hibernate.envers.track_entities_changed_in_revision">true</property>
<property name="org.hibernate.envers.audit_table_suffix">_</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">jta</property>
<property name="hibernate.current_session_context_class">jta</property>
<property name="jta.UserTransaction">java:jboss/UserTransaction</property>
<property name="hibernate.connection.datasource">java:/PersistenceDS</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property
name="hibernate.transaction.transaction.jta.platform">org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.bytecode.use_reflection_optimizer">true</property>
<property name="hibernate.connection.isolation">2</property> <!-- read committed -->
<property name="hibernate.generate_statistics">false</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="hibernate.hbm2ddl.auto">validate</property>
<mapping class="com.ail.core.ForeignSystemReference" />
<mapping class="com.ail.core.Note" />
<mapping class="com.ail.core.Reference" />
<mapping class="com.ail.core.Type" />
<mapping class="com.ail.core.audit.envers.Revision" />
<mapping class="com.ail.core.document.Document" />
<mapping class="com.ail.core.document.DocumentContent" />
<mapping class="com.ail.core.document.DocumentPlaceholder" />
<mapping class="com.ail.core.document.DocumentRequest" />
<mapping class="com.ail.core.key.UniqueKey" />
<mapping class="com.ail.core.logging.ServiceRequestRecord" />
<mapping class="com.ail.core.product.ProductChangeEvent" />
<mapping class="com.ail.core.product.ProductUpgradeLog" />
<mapping class="com.ail.financial.CurrencyAmount" />
<mapping class="com.ail.financial.DirectDebit" />
<mapping class="com.ail.financial.Eway" />
<mapping class="com.ail.financial.IWinPay" />
<mapping class="com.ail.financial.MoneyProvision" />
<mapping class="com.ail.financial.Orange" />
<mapping class="com.ail.financial.PaymentCard" />
<mapping class="com.ail.financial.PaymentHoliday" />
<mapping class="com.ail.financial.PaymentMethod" />
<mapping class="com.ail.financial.PaymentRecord" />
<mapping class="com.ail.financial.PaymentSchedule" />
<mapping class="com.ail.financial.PayPal" />
<mapping class="com.ail.financial.SagePay" />
<mapping class="com.ail.financial.Stripe" />
<mapping class="com.ail.financial.ledger.Account" />
<mapping class="com.ail.financial.ledger.AccountingPeriod" />
<mapping class="com.ail.financial.ledger.Balance" />
<mapping class="com.ail.financial.ledger.Journal" />
<mapping class="com.ail.financial.ledger.JournalLine" />
<mapping class="com.ail.financial.ledger.Ledger" />
<mapping class="com.ail.insurance.claim.Claim" />
<mapping class="com.ail.insurance.claim.ClaimRecovery" />
<mapping class="com.ail.insurance.claim.ClaimSection" />
<mapping class="com.ail.insurance.policy.AssessmentSheet" />
<mapping class="com.ail.insurance.policy.Asset" />
<mapping class="com.ail.insurance.policy.Broker" />
<mapping class="com.ail.insurance.policy.Clause" />
<mapping class="com.ail.insurance.policy.CommercialProposer" />
<mapping class="com.ail.insurance.policy.Coverage" />
<mapping class="com.ail.insurance.policy.PersonalProposer" />
<mapping class="com.ail.insurance.policy.Policy" />
<mapping class="com.ail.insurance.policy.Section" />
<mapping class="com.ail.party.Address" />
<mapping class="com.ail.party.ContactSystem" />
<mapping class="com.ail.party.EmailAddress" />
<mapping class="com.ail.party.PartyRelationship" />
<mapping class="com.ail.party.PartyRole" />
<mapping class="com.ail.party.Party" />
<mapping class="com.ail.party.Person" />
<mapping class="com.ail.party.PhoneNumber" />
<mapping class="com.ail.party.Organisation" />
<mapping class="com.ail.util.DateOfBirth" />
</session-factory>
</hibernate-configuration>
Also in D:\OpenUnderWriter\OpenUnderWriterRepo\system\target\liferay-portal-6.2-ce-ga6
directory, I don't have portal.properties
file. The only props files I have in it are portal-ext.properties
and portal-setup-wizard.properties
. The contents of portal-ext.properties
are as follows
index.on.startup=true
javascript.fast.load=false
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.password=password
jdbc.default.url=jdbc:mysql://localhost/OU_trunk_trunk_Liferay?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=openquote
layout.user.private.layouts.auto.create=false
layout.user.private.layouts.enabled=false
layout.user.public.layouts.auto.create=false
layout.user.public.layouts.enabled=false
theme.portlet.decorate.default=false
velocity.engine.restricted.classes=
velocity.engine.restricted.variables=
web.server.https.port=8443
users.screen.name.allow.numeric=true
company.default.home.url=/web/ou/welcome
and contents of portal-setup-wizard.properties
are as follows
admin.email.from.name=Adam OpenUnderwriter
liferay.home=../..
admin.email.from.address=adam@openunderwriter.org
setup.wizard.enabled=false