Techniques For Integrating Hibernate Into Legacy Java Code – Part 1
If you’re like me, you spend a lot of time dealing with legacy code that, for whatever reason, does not take advantage of modern methodologies and libraries. I’ve taken over Java projects that contain hundreds of thousands of lines of code and not a single third-party jar other than a JDBC driver! One of the most common examples of this is the implementation of the data access layer. These days, the de facto methodology involves Hibernate and DAOs, usually managed by Spring.
This article will detail the steps I recently took to covert a large application from custom-written data access to Hibernate and Spring using the refactoring facilities in Eclipse. The key with this refactorization is to get the existing business logic code (Struts Actions, JSPs, Delegate classes, Business Service classes, etc.) to access the datastore using Hibernate, managed by Spring, without manually changing any of that code directly. Part 1 will include creating the Hibernate data object classes, DAOs, and refactoring the existing code to work with these newly created types. Part 2 will conclude the project with integration of the Hibernate DAOs and wiring everything up with Spring.
First of all, we need to create our Hibernate model and DAO classes. Obviously, since we’re dealing with a legacy application and data structure, we will want to use a bottom-up approach to building our data access layer. This just means that we’re going to generate the Java code and appropriate Hibernate config files from the existing database. There are many tools freely available to make this process very painless. I recommend an Eclipse Plugin for creating and maintaining the Hibernate artifacts (Google “Hibernate Eclipse Plugin” to get started). The structure and requirements for creating Hibernate classes and config files are well documented elsewhere, so I won’t go into detail here. However, in this particular project, the Hibernate DAO lifecycles are managed by Spring, so the DAO classes should all extend HibernateDAOSupport.
Now we have java classes (POJOs) which map to our database tables, but none of the existing code uses these new data object classes. This is where the refactoring tools of Eclipse comes in really handy. For example, say we have a legacy class called AccountInfo which corresponds to the ACCOUNT database table. Right-click the class and select Refactor -> Extract Interface. On the dialogue box, call the new interface IAccount and make sure you select “Use the extracted interface type where possible.” Choose the other options according to your preferences. Click OK and kick back while Eclipse changes every occurence of AccountInfo references to IAccount references and recompiles. Of course, do this with each object model class.
If you never realized why OOP languages are so great, you’re about to. Now we’re going to refactor the code so that all of the existing legacy can be hooked into the new Hibernate model classes instead of the legacy ones. Continuing with the AccountInfo example, create a new class – you’ll probably want to create a new package for this step – called Account that extends the Hibernate POJO for Account and implements the new IAccount interface.
This next part is the most time-consuming, but really isn’t that bad. At this point, the newly created class will probably contain a bunch of empty methods containing only TODO comments. This is because the IAccount interface most likely defies a bunch of methods that are not implemented in the Hibernate Account POJO. To deal with these, we basically want the new Account class to delegate to its generated superclass whenever necessary to satisfy its contract as an IAccount type. As a real world example from the application I was working on, the legacy AccountInfo class defined a getter/setter pair for a property called username, whereas the corresponding column in the ACCOUNT table was actually LOGIN_NAME. To deal with this, you would simply implement the get/setUsername methods in Account to delegate to get/setLoginName (from its superclass). I also had to translate between various data types quite a bit. For example, the legacy code would define many properties as Strings even though the corresponding piece of data in the database was defined as an INT or TIMESTAMP. Again, do this with each object model class.
To finish up the data model layer, edit the appropriate Hibernate and Spring configuration files to refer to these new object model classes. The application now has the ability to map database records to Java objects via Hibernate, and the legacy code which refers to these classes has not required any editing by hand. To finish up this refactorization project, we need to hook in the Spring-supported Hibernate DAOs in a similar way. In Part 2 of this article, I will discuss refactoring the legacy code to read, write, and update data using Hibernate and Spring.
How To Download iPod Movies In 10 Easy Steps
The invention of the iPod makes it easier than ever to take along your favorite media. Whether you’re interested in movies, TV shows, music videos, or sporting events you can now take all your programs with you. The iPod is one of the best portable media devices to come along in years.
One frequently asked question is how to download iPod movies to the device for viewing at a later time or on a later date. Your first objective should be to join a network that allows you to download movies to your iPod. There are many networks across the internet that sell iPod movie download subscriptions. Generally speaking, you will get the best value for your money if you can find a network that allows you unlimited iPod movie downloads for a one-time subscription price. Beware of the websites that ask for a sign up fee, then also hit you with a fee for every movie you download. If you love to download iPod movies, the download fees can add up quickly.
Once you have your network account set up, just follow these 10 easy steps to download movies to your iPod.
1. Browse your chosen iPod subscription network for the movie, video or sporting event you want to download.
2. Once you find the desired movie, you should be able to click the video’s title, image thumbnail or download button.
3. Look for the ‘Video iPod/Sony PSP’ option in the drop-down menu. It should appear on the video’s playback page. Please be aware that you can only download the movie if your iPod has video capabilities.
4. Choose ‘Video iPod/Sony PSP’ from the drop-down menu and then click download.
5. Save the movie or video on your computer in a location you will remember.
6. Now you can connect your iPod to your computer.
7. Open the Apple iTunes application. Select ‘Add File to Library’ from the ‘File’ menu in the iTunes application. Browse your computer for the video you previously downloaded and click ‘Open.’
8. click ‘Edit,’ then click ‘Preferences in the iTunes application. Next, click the ‘iPod’ tab, then click ‘Videos,’ and then ‘Automatically update all videos.’ Lastly, you should click ‘OK.’
9. The iTunes application will copy the movie to your iPod automatically.
10. To play back your movie on your iPod, click ‘Videos,’ then click ‘Movies’.
That was the down and dirty, quick lesson on how to download iPod movies. A good source of helpful information should be the user’s manual that came with your iPod or customer support from the maufacturer. The best sources of helpful information are friends who already own an iPod and have some experience with the device. They can also help you learn how to download IPod movies for your enjoyment.
Find and download Movies, Music and your favorite TV series (even old-time favorites), get full episodes and seasons of the hottest shows around! Download iPod Movies and get a free Mp3 player with your subscription.
Samsung G600: Game for Life
Over the years Samsung has established itself as a stalwart in the thriving mobile phone industry. This South Korean electronic giant has given the world an exciting range of handsets in the last few years. Be its exciting D-series, or slim E-Series, Samsung has brought a sea change in terms of mobile phone features and functionalities. After creating huge sensation among the consumers with their feature rich stylist handsets Samsung is again bringing another member to its league, this time under the G-Series category, called the Samsung G600.
The Samsung G600 is a heavily loaded slider phone in an attractive casing. The handset measures 102 x 47.8 x 14.9 mm and weighs 105 grams and works on Quad Band technology, ensuring simfree use across many countries. The display feature is magnificent – the phone has got a 2.2 inch 16 million colour TF screen supported with a resolution of 320 x 240 pixels. The phone stands tall above the rest with its stunning imaging feature. Equipped with a highly impressive 5 megapixel camera with autofocus and flash, the phone works great for any occasion – birthday, wedding, family get-together or anything else.
Music features in the phone are also superb. The Samsung G600 houses an integrated music player as well as a stereo FM radio. For those game lovers, the the device turns into a complete gaming console – it features embedded Java games as well as supports downloadable games. With 55MB internal memory and MicroSD memory card option, you can keep your entire world of entertainment with you. Connectivity features in the phone are also brilliantly incorporated – thanks to feature like Bluetooth A2DP, USB, EDGE and GPRS. The Samsung G600 carries some more features such as WAP 2.0 XHTML, NetFront HTML, TV Output, mobile printing, email support, handsfree speakerphone etc. All in all, the Samsung G600 is a complete package.
Mobile Phones a complete stand of offers you Samsung U600 mobile phones with best networks on Samsung G600 with 3 to 12 months deals.
Application Migration â?? 26th March, 08
With the increasing expectations and demands of the industry, re-engineering and migration to modern applications has taken a forefront. Let us in this article take a deeper look into the subject along with the benefits.
Why Binaryâ??s Application Migration?
Evolution comes as a part and parcel to all businesses. With fast changing technology, the need to have a reliable and robust system to obtain customer satisfaction has become essential for business to thrive. Enterprises are rapidly opting for application migration to achieve this and their long term future goals.
Maintaining legacy systems sometimes becomes an expensive affair which might also require extra resources. Apart from this, the architectures and design of the application is sometimes very complicated. At times it also gets difficult to integrate the legacy systems with the other systems. In todayâ??s modern day it has become difficult to find resources that will have proper knowledge to maintain legacy systems. Offshore Application Migration is the answer to all these problems.
Binaryâ??s Application migration is the most reliable and efficient method to refresh your legacy systems. The existing system is transferred to a modern and latest platform which increases the overall efficiency of the system. It is also kept in mind to maintain the basic core values of the existing system. Apart from this, you application is also made secure so that your business critical data is accessible only to the decided users.
Most of the experienced companies that offer application migration services
analyze your application and requirements and accordingly plan a detailed roadmap for the migration with the least botheration to your day to day execution of work. The application is tested thoroughly before being delivered to the client. There is a complete transparency if the client needs to monitor the process. If required, a training session on the upgraded application is also provided.
Benefits
Migrating legacy systems to better platforms helps gain efficiency in the particular process apart from increasing the overall speed and reducing your costs and resources. Other benefits include:
? Enhanced operational efficiency
? Improved architecture
? Integration with other existing system
? Get the benefit of recent platform
? Saves time otherwise to be spent on legacy system
? Maintains the core value
? Integration with other systems
? Centralization of business modules
? Improve business visibility
Types of Binaryâ??s Application Migration
Application migration is largely conducted in four platforms – .Net Application Migration, Java Migration, Database Migration and Oracle Application Migration.
.Net Migration
Migration to .Net migration has brought multiple benefits to enterprises. It supports easier integration in businesses and with their customers. It helps save time and money with the added benefit of improved management of the application and processes.
Java Migration
With the popularity of Java, more and more companies are opting for Java migration since it is cost effective and less expensive than re-developing complex applications.
Database Migration
Database Migration is a critical job that involves the migration of the data from the older application to the upgraded version. It is made sure that all your mission critical data is kept safe and accessible only to the users.
Oracle Migration
Our Oracle upgrade and migration solutions help transform legacy applications into modernized, user-friendly solutions that are responsive to current and future business demands
Application migration has become a popular alternative rather than buying new applications. It companies globally are providing expert migration services to help clients boost their business.
Resource:
Application Management| binary semantics | Services
