Monday, September 17, 2007

Hibernate Notes

Here's some Hibernate notes for beginners out there. I've been facing lots of troubles dealing with Hibernate. I hope my notes would be short and clear enough so that you guys could save some time instead of looking for answers in the thick book!

1) Don't get confused with Flush Session & Commit Transaction
I used to have a wrong concept that flush session usually means data is already sync from Hibernate Session to the Database and everything cannot be roll back anymore! This is obviously wrong! Both are irrelevant with each other in fact! Even tough flush session would sync everything from Hibernate Session to the Database, however if the unit of work is within a transaction scope, the developer should trigger a commit so that everything can be committed!

2) Session Save will assign an identifier value to the corresponding saved object
Calling hibernate session save() will not only persist your pojo, but will also assign an identifier to that pojo according to the Hibernate Mapping. The identifier assignment will not be that late until database-session sync process happen.

Wednesday, July 25, 2007

What makes a software project fail?

Came across an article discussing the factors of why software project fails:

Take a look!

I agree with the 3 pillars, which are:
  1. Version control
  2. Work item tracking
  3. Build system
When i review these points on my current project, which implemented a great build procedure, good version controlling, good bug tracking system, and compare to previous projects which did not implement one of the 3 important items, the time saved is really significant!

First of all, a better tool for version controlling was introduced: SVN, then he started to come out with all kinds of ant build script to basically compile the source codes, moving files, deleting files, ftp files and etc. We even have a build script to refresh the whole database schema by deleting tables, drop users, creating new tables, running data scripts and etc. Lastly, we integrated these two important features into our LDAP system. We applied LuntBuild as a better framework to control the build, we applied Trac which provides a lot of features to govern or track bugs.

With the help of all these tools, we managed to save really lots of time on the deployment! The deployment can be easy & clean! Everything is handled at one end, no other parties could interfere the integrity!

Of course, there are weaknesses too, we did not manage to deploy part of the system. For every deployment we are about to do, we got to build the whole project & deploy to the server directory & in the end run some unix scripts which basically unjar the war file & restarts the web application.

Saturday, June 16, 2007

Hibernate Tips - managed sessions

This is a good Hibernate tips. It's another way of handling Hibernate Session.



http://www.17od.com/2006/11/06/using-managed-sessions-in-hibernate-to-ease-unit-testing/





Powered by ScribeFire.

Wednesday, April 25, 2007

Java Programming Tips

Share with you guys of some coding performance optimization tips:

1) Always use isEmpty() rather than size()>0 to check whether a collection contains any object. For further explanation, please read http://hanuska.blogspot.com/search/label/java

2) Always use iterator to iterate your list rather than using for loop and get(int). For further explanation please read http://forum.java.sun.com/thread.jspa?threadID=530365&messageID=2555464

Friday, February 16, 2007

Web Service at JRun 4

Would like to share my way of developing web service & testing it at JRun4 Web Server. I assume you know the concept of web service as this tutorial is specific to web service running on JRun web server. Also i assume you have already known how to use the Eclipse Web Service function which allows you to generate web service related files within a few seconds.

  1. To publish a web service at JRun 4 is very simple, what you need to do is to only create the "wsdd"(web service deployment descriptor) file and place it under your "PROJECT_HOME/WEB-INF/" folder.
  2. Start JRun server for your project. Create WSDL file by just running your project's web service's URL appended with '?WSDL'. For e.g (http://localhost:8103/services/ProgramWs?WSDL). For this case, "http://localhost:8103/services/ProgramWs" is the path to test the validity of web service ProgramWs.
  3. Using the generated WSDL file, go to command prompt, go to your WSDL location, run this command (before that, make sure that you have set JRUN_HOME/bin to your environment path) wsdl2java xxx.wsdl d:/ where xxx.wsdl is your wsdl file while d:/ is the output directory of the generated java classes. Thus, the bean object will be generated. What you need to do now is to replace your original bean object with it. For e.g. Your web service is about to get all programs of an institution, you will have a "getPrograms()" method which returns an array of Program bean object. So just replace this Program object with the auto-generated one which contains additional code for the web services.

Thursday, February 1, 2007

Wanna try these frameworks out

I hope within the next few months i will be able to try these technologies out:

1)Ajax Framework - After doing some research, i found out combination of scriptaulous with Prototype.js is the best Ajax Framework on market so far, even better than Google GWT, amazing ha!

2)Business Logic & ORM framework - EJB 3.0: This framework has reduced the complexity for developers thus started to gain back popularity among the java developers esp. those who are keen on using Spring + Hibernate now. The advent of Java 5 has indirectly sped up the birth of this framework, hope by using it can really ease my job, hihi.

3)Web Framework - Struts is getting obsolete and outdated already. So far it is the most successful web framework. There is a group of its followers are still figuring out how to push it further forward (currently known as Struts TI). I still got hope in this framework.