Skip to main content

Posts

Showing posts with the label Hibernate

Java : Get the Values In An Annotation Using Reflection

Recently I was researching on implementing lucene search (using Hibernate Search). Although I found success with it, I wanted to automate the process of passing the fields that are indexed and their respective index names. Hibernate Search uses a bunch of annotations in the getter to specify their index name and filters used. My Requirement I want to go through all the 'Field' annotation present in every method defined inside my class and get the value of the 'name' field from it. Sometimes 'Field' is present inside as a nested annotation inside 'Fields'. Here the tricky part is where you've to set YourAnnotation ann =  method.getAnnotation(YourAnnotation.class) and get an the annotation object from it. Here is an example problem: Here is the solution: And here is my output... 

Hibernate Search Overview Tutorial

Hibernate Search enables your Java based web application to search huge number of records in the database in a very short timespan. It gives you the functionality as good as the big players like Google and Yahoo. Due to the vastness of information available today and the chaos it makes, a search box has become an integral part of any application that's launched now. The Hibernate search is designed with to work for such kind of scenarios. The best thing is, its easy to integrate. Once you learn the concepts, you can integrate it to your current application while you sip your coffee and see the results in seconds. The complex areas of search index creation, traversal etc are done by Hibernate search silently behing the scenes. Amazon.com is a typical example of a web application offering brilliant search service. Most of the time users don't know exactly what they are looking for, it's the search engines responsibility to "guess" the users mind with the most releva...

Hibernate Reverse Engineering Tutorial For Eclipse To Generate Java Classes From Oracle db

This tutorial will lays the ground work and help you learn how to generate your corresponding java entity classes from the database tables alone. Generating the java classes form the db schema via hibernate reverse engineering tools could save you tons of time if you're setting up a new project. I haven't rewritten the steps that's already published by someone, but I've organized them in a way that will be 'practically' helpful for any newbie who cannot get it right directly from the tutorials I've mentioned here. This is more of a kind a log of things I actually did while I referred these tutorials. 1. Download hibernate tools, only tools. From this tutorial in mkyong.com to install hibernate tools . 2. Create a java project 'HibernateExample'. 3. Do the steps mentioned in mkyong.com to generate the code from with hibernate . 4. Select the jar file (ojdbc.jar) from lib folder of apache tomcat if required. 5. Click on 'Test...