Tag: Hibernate

I have spent mucho time trying to get some named parameters working in the “order by” clause of a dynamic sql query that I’m building. The query isn’t even HQL/JPQL. It’s native. And yet, it turns out that you cannot use bind variables, named or ordered, in an order by clause.

I’m working on a project that utilizes JPA/Hibernate as its ORM. I was writing a few named queries for an JPQL/HQL delete and was getting an SQLGrammarException. I soon found out that I couldn’t use inner joins on a delete statement, even at the SQL level. Here’s the query transformation:

Hibernate’s @Enumerated annotation seems much too brittle in the case of using it with EnumType.ORDINAL. If you’re using EnumType.STRING, I think it works beautifully. This is because the annotation can use the name of the enum to make the mapping. In the case of ORDINAL, the value of the enum is used. This presents a couple problems…

Meet the new web. The simpler the better. The cleaner the better. The more pleasing the colors the better. The fuzzier feelings the better. The latest fuzzies have been brought on by a slew of modals. Previously, we haven’t used many modals in our layouts and designs, so here’s the first working pattern on how to get this kind of stuff working.

This solution allows content to appear in a modal, validation errors to post back to the modal, edits made in a modal to persist back to the database, and success messages to appear on parent page.

Our goal is to create a history audit tool that fires automatically, tracks only selected fields, categorizes those fields, and saves old vs. new data.

We’ll cover interceptor config, data types, dependency Injection, and alternate EntityListeners.

The one option that I found that met all these requirements was the Hibernate Interceptor. There may be better alternatives for you if your requirements differ.

The object-relational mapping world of JPA and Hibernate has made a lot of things really nice and easy. As with any framework of this sort, however, it becomes frustrating when the pieces that are supposed to provide magic ease of development do not work as expected. The frustration is only exacerbated when the docs are skimpy.

Type conversions usually happen automatically in JPA, but possibly due to some databases incredibly not having implemented boolean fields yet (Oracle and pre-5.0 MySQL), an extra bit of help in conversion is needed.