Introduction to JPA

Well its that time of my career where you need to sharpen yourself again to find stumble on the right career path for you and for me it means finding the right project. Originally being a Linux, C/C++ guy, I couldn’t simply ignore the Java buzz and the importance different pieces of Java plays in the architecture world.

Talking about architecture, database enabled Java enterprise applications are of prime importance as they form the basic of any application deployed in the enterprise world.Taking it a bit further,knowledge of persistence APIs are a must have skills in your resume if you want to survive the competition. So this multi-part blog is an effort to help programmers like me to deep dive into the basics of persistence with Java.

2006 saw the final release of EJB 3.0 which was based on JSR-220 (Java Specification Request). This release gave the programmers the ability to store and retrieve application data to and from the database respectively.  This set of APIs is known as the Java Persistence API  or JPA. JPA incorporates many of the concepts and standards from leading persistence frameworks like Toplink (from Oracle) and Hibernate (from JBoss). One of the great benefits of JPA is that it is an independent API and can nicely integrate with J2EE as well as J2SE applications.

By plain definition in Java terms, Java Persistence API (JPA) provides POJO (Plain Old Java Object) standard and object relational mapping (OR mapping) for data persistence among applications.

So what is POJO?

Plain Old Java Object is a term used to refer Java objects that do not extend or implement some specialized classes. The following classes are not POJO classes because the first one extends a specialized class and the second one implements a specialized class.

    class MyServlet extends HttpServlet {}
    class MyRemote implements SessionBean {}

What is Object-Relation Mapping?

OR Mapping – Object-Relation mapping is the process of the transformation of the data between the class objects and databases. Applications can depend on an OR-M like tool that greatly simplifies this work instead of manually coding the transformation process.

Entities

Persistent Data normally refers to permanent data in an application. The state of these data is made permanent by storing them in a persistent medium like database, files or a disk tape. In JPA terms, these persistent data are referred as entities. An entity refers to a logical collection of data that can be stored or retrieved as a whole. For example, in a banking application, Customer and BankAccount can be treated as entities. Customer name, customer address etc can be logically grouped together for representing a Customer entity. Similarly account number, total balance etc may be logically grouped under BankAccount entity.

Since entities form the heart of the JPA, they have some unique properties like

  1. Persistability:- deals with the storing and retrieving of entity from and to a persistent medium like database.
  2.  Identity:- is usually used to identity one unique entity among multiple entities (or multiple entity instances) in a database.
  3. Transactionability:- CRUD operations (Create, Update and Delete) for entity objects will occur within a transactional context and it is one of the major characteristic for an entity object as the real state of an entity depends whether a transaction completes (commits/fails) or not.

Next article in series:- Creating entity classes.

Earlier TechCrunch reported of Google registering a slew of .com domain names related to music and clouds.  These domain names included GoogleBass.com, GoogleAlto.com, GoogleSoprano and GoogleTenor.com along with GoogleNebula.com, GoogleThunder.com and GoogleLightning.com. These domains were registered around the 1st week of April.

In another more recent development, Google has acquired PushLife a Toronto based mobile startup company for $25 M. The PushLife platform enables you to port your iTunes and Windows Media player libraries to non-Apple phones like Android and Blackberryand also lets you manage wallpapers, music, videos, ringtones and other media on your cell phone.

Clearly Google has made up its mind to move beyond search. In another development; YouTube, Google’s popular video platform announced on Friday that it is getting in live stream services (something similar to UStream). This will be available via YouTube.com/live.

So is Google ready to barge in to the media world with full force? I think yes with

  1. A popular video platform supporting live events.
  2. A Google TV appliance
  3. An extremely successful advertisement business
  4. A successful mobile OS

With just a music service to fill in the void, Google would have all that one would need to dominate the media over the Internet.

The US government may have legalized Jail breaking the iPhone, but think twice before you jump on the bandwagon to jailbreak your iDevices powered by iOS 4 and above.  The new web-based jail breaking technique JailBreakMe 2.0  has some substantial security risks. The JailbreakMe 2.0 “Star” exploit tool for iOS 4 and iOS 4.01 devices – iPad, iPhone and iPod Touch, allows malicious access to your phone, via websites.

Well before you really think that this jail break technique actually leaves a backdoor on your device, let me tell that’s not the case. What a jail break, really does is prevents you from getting the fixes and patches from Apple for security issues and loopholes already present in the device. To add to this, jail breaking allows scripts from websites to bypass the restrictions of the device and load malicious code to your iOS device allowing them access to your contacts in the address book, text messages, stored files, memos and what not!

wwwery.com reports of a malicious exploit that has surfaced so far is a “PDF JailbreakMe Exploit,” that allows loading PDFs with malicious code without user prompt. However “PDF Loading Warner” has also been released, which attempts to plug this security hole.

The real issue with jail breaking the iOS 4 is that you will have to keep a track of these individual issues/exploits as they surface and might not even realize when your personal data on the device has been compromised. Also from my personal experience of jail breaking a 3.x device, I experienced a degrade in the performance of the device as well as in its reception capability.

So my advice, stay away from jail breaking as long as you can!

Indian Rupee  joined the elite club after India showcased it’s economic prowess by launching an unique symbol for it ( ). The other currencies in the club being the Euro, US Dollar, Japanese Yen and British Pound Sterling. Indian computer manufactures have promised that the symbol will be incorporated in the keyboard layout within 3 months as soon as it is made standard, a Mangalore based company named Foradian Technologies Pvt Ltd has already come up with a font supporting the symbol. The font is free to use and is available for free download from their blog. The instructions on how to use this font is pretty simple and detailed on their blog.

Foradian Url for font download : http://blog.foradian.com/rupee-font-version-20

Have fun!

The 3 level parking garage in my apartment property 300 Prospect Ave, Hackensack, NJ collapsed this morning. The incident happened in the parking area under the high rise tower building. I live in the mid rise tower but the parking there is accessible via the parking area of the high rise tower. I used live in the high rise tower till Jan this year and moved to the mid rise since. Here are some pictures from within the parking garage that I took from my iPhone, the view of the rubble and devastation. I sent these to News 12 NJ as well and they showed some of it on air as V-clips.

This slideshow requires JavaScript.

When Apple announces launch of any iPhone related stuff be it the OS or device itself, the entire web goes crazy. Perhaps nothing else on the Internet other than those trojans, can generate such a traffic on the Internet. So like others I also joined the craziness bandwagon and tried to find out what Apple has packed for us in the new iPhone 4.0

A new name
Since iPhone OS is being used in iPhone, iTouch and iPad it will no longer be known as iPhone OS, from now it on it would be rather iOS 4. Fair enough!

Multitasking
After a long time iPhone will finally have the multi-tasking capabilities, might sound lame to a few people from the multi-tasking world, but Apple had it’s own reason to avoid multi-tasking till now. As always they managed me amuse me. If you are an entrepreneur  it’s always a good idea to challenge your people when it comes to creativity. That’s what apple does the best. Challenged it’s developers to add multi-tasking and still maintain battery life, viola we have selective multi-tasking. What Apple really did is went over all the applications it has in the app store and determined the kind of applications and the kind of multi-tasking they would need and from this pool selected the services and exposed them as kernel APIs. Neat way huh.

Unified E-mail
iOS 4 gets a unified in-box for multiple e-mail accounts. It includes threaded e-mail conversations and the ability to delete all conversations at once. As of in the older generations of iPhone, if you have setup multiple mail boxes you have to switch between mailboxes to read mails. The new OS now allows you to read them in a single view. It would be interesting tough to see how they are going to manage multiple folders in the mailboxes. I’ll wait to see that.

Folders
If you always thought that your applications are kind of unorganized on your iDevice (that’s a generic term I like to use for either iTouch, iPhone or iPad) and that dragging applications between pages can be boring, well now Apple has folders just for you. You can now create folders by dragging one app on top of another, a good way to create a sort-of application launcher. You can rename folders and drag on more apps at any time.

Camera software
The new iPhone camera has a lot of wow factor for me, the camera hardware is bumped up from 3 megapixels to 5, the onboard software gets 5x digital zoom and tap to focus. I wish I had that feature on my iPhone.

Video conferencing
Taking advantage of the front-facing camera is support for video conferencing. FaceTime, as it’s called, works over Wi-Fi in landscape or portrait mode for any iOS 4 device with a front-facing camera. Wi-Fi only for now, but 3G support may be soon on it’s way.

HD video recording
Ok movie makers this is potentially for you, one of the new features that iOS 4 adds  is a high-def recording rate of 720p at 30 frames per second and allows you to share the video in a single click. Mind the battery as the LED flash is always on during the recording. I won’t be surprised if Apple launches its own Mobile Movie Competition after this to beat Nokia Mobile Movie Competition.

iMovie for iPhone
Apple did provide you with a HD camera and it also provided you with the iMovies app using which you can edit HD videos from the phone. From there, you’ll be able to MMS, share videos via MobileMe, YouTube, and e-mail–but notably not through Facebook. iMovie will be able to pan and zoom and add effects, transitions, and themes. It will also tack geolocation into the movie titles. You can record videos directly into a video timeline and pinch to change the scale or drag to trim or edit the video. You’ll also be able to choose your export size. iMovie will cost $4.99 in the App Store. Looks like you can setup your own movie studio on your iPhone.

iBooks
The e-book reader war is heating and that is what Apple has brought to your cellphone if you don’t want to put your money behind Kindle, Nook or even iPad, Apple does make sure that they have the share of your money they are eyeing on. Later this month, you’ll be able to annotate, tap to bookmark a page, view and read PDFs, and select between books or PDFs within your iBooks shelves. The table of contents will display all your bookmarks and notes.

There are still other many features like iAd and others which i took the liberty to skip out in my post as I also wanted to talk a little bit about what iOS 4 missed.

The Misses

  1. The Apple vs Adobe war is no secret and so as expected, Flash support is still not it. Apple thinks of Flash as a battery hogging proprietary platform. But well in my opinion, look at any iDevice you won’t even miss Flash. Why the fuss, I don’t need Flash on my iPhone.
  2. FM Radio is a basic feature for most of the phone makers like Nokia, Sony Ericsson etc but Apple decided to give it a miss this time too. I would say why I would need FM radio when I have my own iPod packed in my phone. I would any time prefer to listen my own collection of songs rather than some DJ’s collection.
  3. The File Manager, a central app to manage all your documents, songs and photos on the device, is still not in. I wish this was included in iOS 4.

Availability
Developers get iOS 4 on Monday (i.e. today), which means that the general public won’t. iPhone 3GS, iPhone 3G, and iPod Touch (except the first generation) will get a free upgrade on their existing iPhones on June 21, though not all features will be supported off the bat–for example, FaceCall, which requires a front-facing camera that those devices don’t have.

E-mail: iOS 4 gets a unified in-box for multiple e-mail accounts. It includes threaded e-mail conversations and the ability to delete all conversations at once.

Folders: Create folders by dragging one app on top of another, a good way to create a sort-of application launcher. You can rename folders and drag on more apps at any time.

Camera software: As camera hardware jumps from 3 megapixels to 5, the onboard software gets 5x digital zoom and tap to focus.

HD video recording: New to iOS 4 is a high-def recording rate of 720p at 30 frames per second (and keeps the LED flash on for HD recordings). One-click sharing from the phone.

iMovie for iPhone: The iMovies app can edit HD videos from the phone. From there, you’ll be able to MMS, share videos via MobileMe, YouTube, and e-mail–but notably not through Facebook. iMovie will be able to pan and zoom and add effects, transitions, and themes. It will also tack geolocation into the movie titles. You can record videos directly into a video timeline and pinch to change the scale or drag to trim or edit the video. You’ll also be able to choose your export size. iMovie will cost $4.99 in the App Store.

Video conferencing: Taking advantage of the front-facing camera is support for video conferencing. FaceTime, as it’s called, works over Wi-Fi in landscape or portrait mode for any iOS 4 device with a front-facing camera. Wi-Fi only for now, but Jobs hinted that 3G is coming.

iBooks: Later this month, you’ll be able to annotate, tap to bookmark a page, view and read PDFs, and select between books or PDFs within your iBooks shelves. The table of contents will display all your bookmarks and notes.

Bing: Apple is adding Bing to iPhone’s search. You’ll be able to choose Google, Yahoo, or Bing for your search engine.

Enterprise integration: Data protection, device management, wireless app distribution, deeper VPN support, and support for multiple Exchange accounts (and Exchange Server 2010) are coming to iOS 4.

iAds: A new ad platform builds ads into apps, and keeps the app experience bound within the app. Translation: You won’t get kicked out of the app if you click an ad.

Miscellaneous additions: Half curl page transitions and draggable map annotations all for app developers.

Availability: Developers get iOS 4 on Monday, which means that the general public won’t. iPhone 3GS, iPhone 3G, and iPod Touch (except the first generation) will get a free upgrade on their existing iPhones on June 21, though not all features will be supported off the bat–for example, FaceCall, which requires a front-facing camera that those devices don’t have.

The following pictures and details were posted on NASA’s website.

388710main_clark_figure_3blue-full

These images show a very young lunar crater on the side of the moon that faces away from Earth, as viewed by NASA’s Moon Mineralogy Mapper on the Indian Space Research Organization’s Chandrayaan-1 spacecraft. On the left is an image showing brightness at shorter infrared wavelengths. On the right, the distribution of water-rich minerals (light blue) is shown around a small crater. Both water- and hydroxyl-rich materials were found to be associated with material ejected from the crater.

Credits: ISRO/NASA/JPL-Caltech/USGS/Brown Univ.

 

388840main_green-b-20090923-516

 

This image of the moon is from NASA’s Moon Mineralogy Mapper on the Indian Space Research Organization’s Chandrayaan-1 mission. It is a three-color composite of reflected near-infrared radiation from the sun, and illustrates the extent to which different materials are mapped across the side of the moon that faces Earth.
Small amounts of water and hydroxyl (blue) were detected on the surface of the moon at various locations. This image illustrates their distribution at high latitudes toward the poles.
Blue shows the signature of water and hydroxyl molecules as seen by a highly diagnostic absorption of infrared light with a wavelength of three micrometers. Green shows the brightness of the surface as measured by reflected infrared radiation from the sun with a wavelength of 2.4 micrometers, and red shows an iron-bearing mineral called pyroxene, detected by absorption of 2.0-micrometer infrared light.

Image credit: ISRO/NASA/JPL-Caltech/Brown Univ./USGS

 

388942main_CARLE_2-516

These graphs show detailed measurements of light as a function of color or wavelength. The data, called spectra, are used to identify minerals and molecules. On the left are spectra of lunar rocks, minerals and soil returned to Earth by NASA’s Apollo missions, taken in the visible to shorter-wavelength infrared range. The blue bar shows where a dip in the light is expected due to the presence of water and hydroxyl molecules. To the left are model spectra for pure water (H2O) and hydroxyl (OH-).

Image credit: ISRO/NASA/JPL-Caltech/Brown Univ.

 

388842main_green-c-20090923-516

These images from NASA’s Moon Mineralogy Mapper on the Indian Space Research Organization’s Chandrayaan-1 spacecraft show data for the hemisphere of the moon that faces Earth. The image on the left shows albedo, or the sunlight reflected from the surface of the moon. The image on the right shows where infrared light is absorbed in the characteristic manner that indicates the presence of water and hydroxyl molecules. That image shows that signature most strongly at the cool, high latitudes near the poles. The blue arrow indicates Goldschmidt crater, a large feldspar-rich region with a higher water and hydroxyl signature.

Image credit: ISRO/NASA/JPL-Caltech/Brown Univ.

 

388946main_CARLE_4-516

Many small, fresh craters bear signatures of water and hydroxyl, which are detected as absorptions of infrared light in the range of 3 micrometers by NASA’s Moon Mineralogy Mapper. Figure A, on the left, shows feldspar-rich terrain on the side of the moon facing away from Earth. The arrows point to the location of small, fresh craters. Figure B, on the right, indicates the reflectance as a function of wavelength for craters in Figure A. The water and hydroxyl signature in these regions is seen as a characteristic dip in reflectance in the infrared light near the 3-micrometer range, a region noted with a light-blue band. The dashed line shows background soil that doesn’t contain significant water or hydroxyl.

Image credit: ISRO/NASA/JPL-Caltech/Brown Univ.