JPA, Hibernate, EJB3 and TopLink quick diagram

22 January 2008

I searched some UML diagram on JPA, Hibernate, toplink, openJPA and EJB3 to get a quick understanding on how they are related to each other. I think that I have a good understanding now, but I found some confusing comparisons along the way.

The best I have found so far is : Java Persistence, implementations, and Java EE servers.

So I bring my own here, take it as a work in progress, open to criticisms : JPA UML Diagram

Note : I used UMLet and examples.

I think that I will add the servers deployment view.

So here is the version 2, a bit more cluttered :jpa1.jpg


Fedora 8 and Java

15 January 2008

Some more informations on Fedora 8 and Java. A new hard drive was a good excuse to do a fresh Fedora install. Even with a fresh install, I had to remove all the i386 package (I have a x86_64 : no need to duplicate all package, this is a known problem of Fedora) and legacy gcj stuff.

I installed Java 7 since it is the future. But since it doesn’t have the crypto features yet, and since they are required for Glassfish, I installed the SUN JDK 6 as well.

So informations are bit misleading on the topic. Here is what I like to do :

Install jpackage-utils, then SUN JDK 6 RPM, then JPackage -compat package for the SUN rpm : java-1.6.0-sun-compat-1.6.0.04-1jpp.i586.rpm.

Manage the Java 6 / 7 switch with galternatives or (command line alternatives)

Remember Java 7 IcedTea install tips :

Mauriat Miranda tips and added the JDK as well (-devel) : sudo yum install java-1.7.0-icedtea java-1.7.0-icedtea-devel java-1.7.0-icedtea-plugin

I tested as per Gregory Gulick’s tips and it was OK.


Maven dependencies an Glassfish

12 December 2007

I am a bit new to Maven2 but it seems like I am not the only one to have problems with dependencies. Looks like stuff related to Sun Application Server (now Glassfish) and the Webservice Stack (now Glassfish Metro) has changed and the repositories moved.

References :


Spaces, shards, scalability through horizontal partitioning

21 November 2007

I just read some GigaSpaces White Paper and application examples.

They sort of applied the database horizontal partitioning (or “Shards”) paradigm  to the application server.

But they tend to alleviate the inherent problem of designing “completely self-sufficient” units. Their example is completely obvious, but in real life partitioning isn’t straightforward !


Web frameworks peaking toward obsolescence ?

20 November 2007

More than a shocking title, there is an interesting debate : See Raible Design.

InfoQ asks Does the rise of Service Oriented UI (SOUI) means the death of server-assisted MVC? A similar thread was started on JavaLobby last week: Web frameworks peaking toward obsolescence. A month ago, TSS posted a whitepaper titled Life above the Service Tier.

I will take the time to read all this !


PHP and JAVA, PHP on JAVA : Quercus

16 July 2007

Sun should have done this a long time ago, but Caucho did it : Quercus !

I quote :

100% Java implementation of PHP 5 released under the Open Source GPL license. Quercus comes with many PHP modules and extensions like PDF, PDO, MySQL, and JSON. Quercus allows for tight integration of Java services with PHP scripts, so using PHP with JMS or Grails is a quick and painless endeavor.

With Quercus, PHP applications automatically take advantage of Java application server features just as connection pooling and clustered sessions.

Quercus implements PHP 5 and a growing list of PHP extensions including APC, iconv, GD, gettext, JSON, MySQL, Oracle, PDF, and Postgres. Many popular PHP application will run as well as, if not better, than the standard PHP interpreter straight out of the box. The growing list of PHP software certified running on Quercus includes DokuWiki, Drupal, Gallery2, Joomla, Mambo, Mantis, MediaWiki, Phorum, phpBB, phpMyAdmin, PHP-Nuke, WordPress and XOOPS.

Quercus presents a new mixed Java/PHP approach to web applications and services where Java and PHP tightly integrate with each other. PHP applications can choose to use Java libraries and technologies like JMS, EJB, SOA frameworks, Hibernate, and Spring. This revolutionary capability is made possible because 1) PHP code is interpreted/compiled into Java and 2) Quercus and its libraries are written entirely in Java. This architecture allows PHP applications and Java libraries to talk directly with one another at the program level. To facilitate this new Java/PHP architecture, Quercus provides and API and interface to expose Java libraries to PHP.

The Quercus .war file can be run on Java application servers such as Glassfish, i.e. it can be run outside of Resin. This .war file includes the Quercus interpreter and the PHP libraries.

Just a few remarks : it is a .war file that can run on other application servers than Resin, this is great ! Some of the features described are only available in the “professional” non-free version of the Resin Server.


Eclipse PHP debug

16 July 2007

There are 2 plugins to do PHP development in Eclipse (obviously they are incompatible) they both should work with Eclipse 3.3 Europa.
They have almost the same features. PDT gets my preference.

There are 3 differents debug engines : DBG, xdebug and Zend_Debug (close source).

  • XDebug
    There are two different protocols to communicate with the debugger: the old GDB-like command protocol (GDB) which is implemented in Xdebug 1.3 and 2; and the DBGp protocol which is implemented in Xdebug 2.
  • DBG is a full-featured PHP Debugger and Profiler.

Profiling client KCachegrind can read XDebug Profiling files.


urldecode for mysql

11 April 2007

It is possible to get the urldecode() or urlencode function in MySql, the same way it exist in PHP as url_decode and url_encode.

You just have to install the User Defined Function : UDF collection for MySQL created by Michael Wallner from IWorks.

There are just a few points to help the installation :

  • Decompress the sources : tar xf libmysqludf-0.3.tar.gz
  • Go into the directory cd libmysqludf-0.3 and read the INSTALL file !
  • If you don’t have them get MySql sources as well : yum install mysql-devel
  • On a RPM style MySql install do a ./configure --prefix=/usr/lib/mysql --includedir=/usr/include/mysql --libdir=/usr/lib (not sure if it is all really needed but it worked on a Fedora Core 5).
  • make
  • sudo make install
  • sudo /etc/init.d/mysqld restart (maybe not needed)
  • Open a mysql client as root if you don’t have the INSERT privilege for the mysql database (CREATE FUNCTION Syntax) : mysql -u root -p
  • There is the trick : CREATE FUNCTION urldecode RETURNS STRING SONAME 'libmysqludf_urldecode.so'; Notice the function name is lower case !!!
  • If you want to remove the function use DROP and then sudo make uninstall

Then you are free to url decode or url encode right in you SQL query ! It is very helpfull when you work on Apache log files !
I search for a Linux command line tool to urldecode, but I couldn’t find one. Still here are some good ressources :

Maybe a solution would be (from Perl FAQ ) :

The best source of detailed information on URI encoding is RFC 2396. Basically, the following substitutions do it :

    s/([^\w()'*~!.-])/sprintf '%%%02x', ord $1/eg;   # encode

    s/%([A-Fa-f\d]{2})/chr hex $1/eg;                # decode
	s/%([[:xdigit:]]{2})/chr hex $1/eg;          # same thing

java 6 on Linux and JPackage

27 March 2007

I wanted a clean install that use alternatives. So I go to JPackage … the point is that they are a bit outdated on a few points :

  • The recommended method “Rebuild the package” doesn’t fit anymore with Java 6. There is only a sun-compat packaeg and no “no-src” package.
  • The repository for Fedora “ready for use” is using mirrors pointing to the 1.6 JPackage version that doesn’t features Java 6. You have to manually write the yum.d/jpackage.repo to use JPackage 1.7.
  • The RPM for java-1.6.0-sun-compat is in the non-free section of 1.7 beta. (Note : there is a 5.0 that is supposed to match Java 5, but no 6.0 so far.

Anyway, I installed the JDK 6.0 for AMD64 from Sun and then the java-1.6.0-sun-compat and it went well. Installed Eclipse 3.2 with yum to try out. It seems OK so far.


Nulls

22 August 2005

Comments on Nulls : Nothing to worry about by Phil Zoio as published in Oracle mag (link to global post)
First you should ask what it means from a business point of view to have a null ! Information missing ? not applicable ?
Then COALESCE, IS NULL, IS NOT NULL are the most obvious functions to avoid problems.
Would you feel safe by using only “NOT NULL” fields in your tables ? No : an outer join will bring them back easily.
In scalar expression : SAL+NULL results in NULL, but in boolean expression : SAL (SELECT MAX(SAL) FROM A) and WHERE SAL > ALL (SELECT SAL FROM A) if A is empty, the first query returns nothing (UNKNOWN) but the second will always be TRUE, because SAL > ALL (NULL) is always true.
Is SUM(SAL+COMM) the same as SUM(SAL)+SUM(COMM) ?? No : Nulls are ignored by aggregates functions !
More tricky : WHERE EMPNO IN (SELECT MGR FROM A) if a MGR is NULL : what do you expect ? Nothing : since EMPNO IN (…, NULL, …) is UNKNOWN or FALSE, the query returns nothing.
Conclusion : there are more than one way to write a query : choose the right one …