Category Archive: Hibernate

Jan
26

Hibernate Enum Datatype Mapping

If you want to map a enum in JPA/Hibernate POJO class, so that only specific values can be saved for underlying database column, it is possible now very easily. The sample POJO File is given below, have an idea. @Enumerated( javax.persistence.EnumType.STRING ) tells what values you want into database from provided enum type, & hibernate will …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/hibernate-enum-datatype-mapping/

Jan
17

Hibernate persist() vs. save()

In case anybody finds this thread… For persist() The semantics of this method are defined by JSR-220. persist() is well defined. It makes a transient instance persistent. However, it doesn’t guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. The spec doesn’t say that, …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/hibernate-persist-vs-save/

Nov
24

Generic DAO with Hibernate and Spring

If you are using Hibernate with Spring, then you will be dealing with huge set of DAOs. In such case best way to minimize the DAO work with Generic DAO patter, which encapsulate CRUD + basic finder method and then write only very required methods. I’m inspired by the IBM Generic DAO pattern and rewrite …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/generic-dao-with-hibernate-and-spring/

Nov
20

How to achieve Database Auto ID Generation Portability in Hibernate

Hibernate meant to be Database independent ORM solution, but while migrating to another database vendor some key issues arrives. One of them is Auto ID generation of underlying database. MySQL, Oracle & MS SQL Server all uses different techniques to generate auto ID for primary keys. So, when we start migrating we face lot of …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/how-to-achieve-database-auto-id-generation-portability-in-hibernate/

Nov
17

MyEclipse Customizing Hibernate Reverse Engineering

Customize Myeclipse Hibernate Reverse Engineering

Most of the time you want to perform hibernate reverse engineering to generate Pojos from underlying database using hibernate-tools or directly from My Eclipse which also uses hibernate-tools. But some times we want to control the mechanism by which hibernate  tools generate pojos, like we want to have prefix or suffix in our class name …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/myeclipse-customizing-hibernate-reverse-engineering/

Sep
05

Hibernate – How to use database’s reserved keywords in HQL and Pojos?

1. Enclose the column name  with square brackets [] will solve your problem. @Column(name = “[ORDER]“, nullable = false) public String getOrder() { return order; } And for Hibernate XML Mapping <property name=”Order” type=”string” > <column name=”[ORDER]” length=”128″ /> </property>

Permanent link to this article: http://www.javaplex.com/blog/hibernate-how-to-use-databases-reserved-keywords-in-hql-and-pojos/

Jul
18

Project Skelton based on Extjs, Strtus, Spring and Hibernate

If you decided to start java web project with UI framework with backed Spring and Hibernate. It also bundled with Extjs which have amazing rich UI components and AJAX support out of the box. Some guys, created a skelton project based on above specs and open sourced it on google code repositry with name “MICRITE”. …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/project-skelton-based-on-extjs-strtus-spring-and-hibernate/

Jun
02

Server side Pagination using JSF Data table and Hibernate

Following is the working example of Dynamic or server side pagination. Your DataModel class JSF Component Util to find datatable at runtime Your Controller Method Your JSF Page

Permanent link to this article: http://www.javaplex.com/blog/server-side-pagination-using-jsf-data-table-and-hibernate/