Minggu, 26 April 2009

Java Persistance with Hibernate - what I had to re-visit after reading the book

I recently had a JPA related issue and decided that it was high time to purchase a good book on the subject; particularly as JPA/Hibernate tend to play a very important role of course.


I ended up discovering "Java Persistance with Hibernate" (Bauer, King). This book is a revision of "Hibernate in Action" and it certainly reads as a complete reference to all things ORM. What attracted me to this book in particular was its coverage of JPA. I prefer to use JPA over Hibernate interfaces so that my ORM implementation choice is left open as much as possible. Having said that Hibernate gives me no reason to move to another ORM.


I must have been using Hibernate/JPA for the past 18 months. When I started I recall wanting to skim over the ORM subject as much possible in order to get things done i.e. I did not think deeply about the implications of some of my decisions; or rather I misinterpreted the way things worked e.g. the 2nd level cache. To this end here is a list of things that I found myself re-visiting:


* property annotations instead of field annotations;

* using the Collection interface instead of the Set interface;

* cache annotations;

* bi-directional one-to-many relationships;

* immutable entities


Using property access can boost performance when performing operations on a collection (also as opposed to a set). For example if you want to add to the collection Hibernate does not have to load the existing collection from the database. If you use a Set then it does in order to guarantee Set semantics.


Understanding the second level cache is very important and if you don't have time to learn it then disable it. It is also a good idea to understand whether you have immutable entities so that you can use the Hibernate @Entity(mutable=false) annotation and flag to the cache that the object is read only. This permits Hibernate a few optimisations including a minimisation on the number of update statements that require preparing at startup.


I always wondered why my bi-directional relationships were generating a join table. It finally sunk in that the mappedBy attribute on an association describes the foreign key. No more join tables for bi-directional relationships.


There's no excuse; just buy the book if you're doing any ORM. Having said that even before I made these changes Hibernate was performing exceptionally well!

Address Bar Default Search Engine

Search engine war cause some confusing effect to our browser. Oneday, withour your consent, when you try to search through Location Bar or Address Bar, the place to type web address, the search result is coming from your unwanted search engine.

In Firefox, to set it back to the previous one, e.g. Google, use the following method

1. open firefox, type in “about:config” in the keyword box (address bar).
2. search for “keyword.url”
3. right click on the URL and select “modify”. Or you can double clik it.
4. change the content to Firefox default: http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=



More info:
http://kb.mozillazine.org/Keyword.URL

Questionnaire to survey the use of the fact Ttoiralbermjiat free (open source) in the Arab World


General Engineering at the Arab interest in the activities of open-source publish the questionnaire on the open source on the General Assembly, which has been under the supervision
Arab Organization for Education, Culture and Science Department of Science and Scientific Research
For more information, please visit the project site

Please help us to mobilize the following questionnaires to be able to deploy the results of the Arab world by the Arab Organization for Education, Science and Culture and support entrepreneurship and help build a nation-wide strategies
Section of companies and organizations and educational institutions
Section of software developers
Or the possible download files Ballglp Arabic or English and sent to us directly by e-mail

admin AT handasarabia.org

Introduction to the Free Software



In the first days of the proliferation of electronic computers (between 1945 and 1975) was the developers of software programs, including the freedom of exchange, in order to exchange experiences and ideas. Even the famous Unix operating system developed by researchers at AT & T was distributed to investors Ktrameez software (with the right of the amendment it) for the symbolic sum.

However, things have changed gradually and became the program development since the seventies and eighties of the last century, the richest source of large developers, which made many of them sell their packaged in boxes sealed for unknown content is only able to modify themselves. And applicable to the Unix system as well.



Free Software / Open Source (FS / OSS)

Emerged in the early eighties of the last century the idea of free software / open source to get rid of the monopoly of proprietary software (commercial / closed), known as the Proprietary Software, which is a closed black boxes for the user knows the maze of schemes and structure can not be adapted or modified without reference to the owning company, which gives the investor the right to use only by leave (often expensive) reservation of the company internationally and control over their rights and how to use the software in question.

Started brilliant programmer Richard Stallman, 1983, at the University of MIT's famous rebellion against the constraints of proprietary software. And succeeded in the compilation of a number of creative scientists around the idea of free software in 1984 and established a non-governmental and non-profit called:

The Free Software Foundation (FSF) Free Software Foundation, and went working in the building of a free operating system (a system similar to UNIX) called the Gnu. They publish their work freely all the steps for the benefit of programmers who can turn the world to assist in the development of this system and benefit from it.

In the early nineties of the last century, the Finnish programmer able illustrious Linus Torvalds, who has been following the development of the Gnu, to complete a central Kernel (linking the various vehicles for the operating system and regulate the relationship between them), called Linux, and strongly developed, taking advantage of the key factors; the speed of communication via the Internet, and the participation of thousands of programmers around the world to criticize and to improve and develop its work. Thus building a free operating system (open source) is known as an integrated, Gnu / Linux (or Linux as the error only); and that was a significant breakthrough for the idea of free software and spread globally.

Free software is built on the philosophy of the following four levels of the concept of freedom:

Freedom 0: the freedom of the investor in the operation and use of software, study and know the secrets and how they work.

Freedom 1: Freedom of the investor is to modify the code and adapt it to the needs and wishes.

Freedom 2: Freedom of the investor in the copy of software and support to help a neighbor or a friend or a colleague or another user.

Freedom 3: Freedom of investment in the deployment of software developers are available.



0 requires freedom, freedom freedom 1 and 3 encoding software to provide Source Code to the investor to understand and be able (if any) to modify and adapt the program commensurate with the requirements. These four freedoms, which are collectively characterized by the free software on proprietary software.
One of the most important legal concepts that he created the modern Stallman is the so-called "People's license" General Public Licence (GPL) which guarantees the continuation of the above-mentioned freedoms in the circulation of free software / open source, for the symbolic sum.

Also contributed to the University of California - Berkeley branch is also the addition of vehicles and many improvements to the system of Unix. In the end, brought together the efforts of Berkeley in the operating system, a strong open-source published in a number of issues:

NetBSD, OpenBSD, FreeBSD.

It should be noted here that the operating system, Mac OS X Apple's built on these issues.