Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Getting Started with gquery (Hibernate)

This is the getting started guide for the Generic Query (gquery) component of the grepo framework. It's not supposed to be a complete reference manual - the goal is to show a basic usage and configuration scenario of grepo's gquery component (using hibernate). If you have problems understanding parts of this guide or the framework in general or if you have any suggestions, good ideas or if you have found potential bugs please let us know. So let's get started!

Version Information


This guide is written for grepo version 1.5.0.

Older versions of this guide

Version 1.0

Download the demo project

The demo project for this guide can be checked out from our SVN repository as follows:

$ svn checkout demo-grepo-query-hibernate

The demo project is a maven project and we highly recommend that you use maven to set up the project. If you don't want to use maven you can also set up the project manually. If you use maven and eclipse you can easily make an eclipse project using the following command in the demo project's root directory:

$ mvn eclipse:eclipse

You can now import the project in your eclipse workspace.

After you have imported the project you should now be able to run the UserRepositoryTest JUnit test. You can also run the test using maven from command line:

$ mvn test

Let grepo tell you what's going on

Grepo uses the commons-logging library. If you set the logger level for the package org.codehaus.grepo to TRACE in (src/test/resources/log4j.xml) like this:

<category name="org.codehaus.grepo">
    <priority value="TRACE" />

Grepo should print out information similar to this:

11:24:56,976 TRACE [GenericQueryMethodInterceptor:54] - Invoking method 'loadByUsername'
11:24:56,977 TRACE [QueryExecutorNamingStrategyImpl:63] - Resolved executor name: load
11:24:56,977 TRACE [QueryExecutorFindingStrategyImpl:68] - Found queryExecutor
                   'org.codehaus.grepo.query.hibernate.executor.LoadQueryExecutor' for execution of method 'loadByUsername'
11:24:56,978 TRACE [GenericRepositorySupport:117] - Executing query using transaction template
11:24:56,978 TRACE [QueryNamingStrategyImpl:89] - Resolved named-query: demo.domain.User.ByUsername
11:24:56,979 TRACE [AbstractHibernateQueryExecutor:152] - Using query: from User where username = ?
11:24:56,979 TRACE [AbstractHibernateQueryExecutor:441] - Setting parameter '0' to 'max'
11:24:56,981 TRACE [DefaultHibernateRepository:91] - Query result is 'demo.domain.User@377f4fbb[id=1,username=max]'
11:24:56,981 TRACE [GenericQueryMethodInterceptor:79] - Invocation of method 'loadByUsername' took '0:00:00.004'
  • No labels