Category Archives: Database

Open H2 UI When Debugging in Eclipse

This time it is about debugging the H2 embedded database, which is very similar to procedure used with the HSQLDB I posted earlier. Assuming that the hibernate.connection.url is set to jdbc:h2:mem:myDb, you can following similar steps as in my previous … Continue reading

Posted in Database, Java, Tool and Debug | Tagged , , , , | Leave a comment

Hibernate Formula Annotated Field Behaviors

When the @Formula annotation is used to create a virtual column (in object model but not in database), developers should be aware of some behaviors to avoid of any pitfalls. This post uses the source code here to demonstrate these … Continue reading

Posted in Database, Java | Tagged , , , | Leave a comment

T-SQL Pivots a Table

This post demos how to pivot a table using both the Pivot function and a home made approach. The code can be found from GIST. Problem An OrderItem table contains orderId, itemName and qty as its columns. Now we want … Continue reading

Posted in Database | Tagged , , | 1 Comment

Use CTE and Table Partition and Ranking Functions to Delete Rows with Duplicates

This post demonstrates to use T-SQL table partition, row_number ranking function, together with CTE to delete duplicated data from a table. The logic is saved in a stored procedure for reuse purpose. Two Tables in the Example: Orders table uses … Continue reading

Posted in Database | Tagged , , , , , | Leave a comment

Use Hibernate Query Language to Join Tables and Map Column Values to Java Objects

The following example creates a HQL statement with named parameters, executes the query then maps the query result back to Java objects. The two named parameters in the example are accountNumber and trackingId. The three selected columns are unitPrice, qty … Continue reading

Posted in Database, Java | Tagged , | Leave a comment

Excel Concatenate String With Cell Value

You can use the “&” operator for this purpose, see the attached screenshot.

Posted in Database, Excel, Tool and Debug | Tagged , | Leave a comment

Query the In-memory HSQLDB When Integrated With Hibernate

HSQLDB in-memory database is often used with Hibernate for testing, prototyping and even in production environment. With Hibernate, you can perform powerful database operations either using the ORM based APIs, HSQL or native SQL. As a developer, sometimes you want … Continue reading

Posted in Database, Java, Programming, Tool and Debug | Tagged , , , | 1 Comment