Hibernate provides an option to lazy fetch single-sided (to-one) associations using lazy proxy or bytecode instrumentation. However, both approaches suffer some problems. Byte code instrumentation … requires byte code instrumentation, while lazy proxies can be really problematic regarding type casting and instanceof
check especially in existing systems and framewors. But don’t worry. In few words below I’ll describe a solution I’ve figured out for the existing system to improve performance using lazy to-one overcoming casting problems and not using instrumentation.
This article will be about multiple joins in Hibernate model during super class fetch in JOINED inheritance mapping strategy, and generally how I significantly improved our system performance using some simple patterns. There’s a lot of stuff on internet about this (usually wrong approach), so here I’ll present my working solution for this problem.
Read the full articleFew days ago I was asked to implement charts with some finance data using JS charting library, in the application working on Postgres database. There’s a lot of finance stuff in the database stored every minute and I just needed to show this data on charts.
OK, but charts are nice if you can restrict amount of your data returned from the server to some limited number of items. Returning 1000 items would both - make chart very heavy and unreadable and consume a lot of net traffic. I assumed 50 as the average number of items that are nicely displayed on such charts and are also acceptable from the traffic point of view.
Read the full articleThis catching title will be not about distributed hibernate search, but something really close :)
The case I’ve recently solved was a quite different. I have a frontend application that uses hibernate database and hibernate search, and then I needed to add additional application - let’s call it an integration server, which exposes some API webservices for the overall system. Integration server uses the same database as the frontend application, and enables clients to put data to the database using its webservices. Both applications exist on two different physical servers, as well.
Read the full articleIn previous BIRT versions there were three ways to use BIRT with your Hibernate datasource:
Previously I’ve been using plain SQL, but with complex database model it becomes very difficult (a lot of properties, joins and other relationships). Scripting data source using javascript is a bit too awkward for me, and certainly adds another level of application complexity, and another level of layers where “the things may go wrong”. Finally, Hibernate ODA data source from JBoss tools - this is what I wanted to use in older times, when I was using Eclipse, but for plain no-jboss application there were a lot of problem with these tools. They seem to be related to SEAM. Anyway AFAIR I had more problems with maintaining proper hibernate configuration in Eclipse (especially that it was partially annotation, and partially XML based) than the value of having working hibernate queries in IDE.
Read the full articleIn the current project we faced the problem of concurrent changes to database, for the data that should be accessed sequentially. Imagine you have the customer’s bank account where he can withdraw the money. If the customer is not a person, but company, and if he can have multiple users accessing the bank application, without any locks there’s a chance for situation where two or more users depute transfers, that exceed the account balance, but because data is accessed concurrently, they both can make payoff.
Read the full articleHere I’d like to describe another interesting case I’ve been struggling with for recent few days. This involves the following use case: enable asynchronous events support for Tomcat/Spring multi-tenancy SaaS application, that can be pushed to listening client groups. To be specific, the event should be channeled to following groups: to specific user, to all users of specific tenant and to all users.
Read the full articleJCA can be really tricky to perform simple, common tasks. After latest usage of java cryptography I’d like to present below the simplest usage of cryptography methods, involving mainly symmetric (AES) and asymmetric (RSA/DSA) encryption plus some helper methods.
Read the full articleApache Tika has a wonderful feature, that can transform source document (PDF, MSOffice, Open Office etc.) into HTML during content extraction, what can be used for example to make document preview directly on webpage without involving any third-party components. Sound pretty simple, but I’ve dug through a lot of google search results and I can’t find a simple working example anywhere.
Read the full articleToday I was playing a little about Play Framework. This is very nice lightweight application framework for Java and Scala. I was trying to make an app and deploy to Heroku, which is a PaaS platform where you can host you Play applications for free (with some limitations of course).
Read the full article