If you use Spring 2 or 3 along with Hibernate and take advantage of the wonderfully declarative annotation development style, you probably have had this same problem as I have. Say you have defined your model objects with hibernate EJB 3 style annotations for your main database. Now perhaps you have several satellite databases that differ slightly from the main database to fulfill auxiliary roles.

You certainly wouldn’t want to package and provide an additional model objects library for the application or specific context using one of these auxiliary databases. Luckily, there is a rather simple solution. Hibernate allows you to override any annotations by providing an XML definition and specifying it in your configuration. The Spring Framework also provides access to this through their applicationContext.xml files during the session factory and DataSource configuration points.

Essentially, you can have a set of overrides for every application context you load allowing access to multiple different databases using the same model library.

My Specific Situation

In my case, I had a well defined @Id column that provided a cross database sequence or identity population using the AUTO generator type provided by the Hibernate libraries. In one of our applications we had a case where the main database was used to create this record, but a duplicate needed to exist on the outside database to fulfill database integrity constraints on an additional table. Sparing, the specific implementation details (which could probably been avoid with better original design), I needed to disable the generator on this object for this application context.

Here is the default configuration as defined based on the main

@Id
@Column(name = "object_id")
@GeneratedValue(strategy = GenerationType.AUTO, generator="some_sequence")
private Integer id;

Here is the XML hibernate mapping override file created in my src/main/webapp/WEB-INF directory along with the application context XMLs for the Spring 3 configuration:


    
      

      
    
  


One important configuration to note is the ‘metadata-complete’ attribute on the entity tag. This attribute defines whether to throw away other configuration metadata defined with annotations on the object and use your configuration exclusively. To do simple overrides this is definitely not the intended action.

To enable the configuration file in spring, the following snippet shows what was added to the application context:




      
    


org.hibernate.dialect.PostgreSQLDialect
true
false
      
    


            com.xxx.persistence.a.object
            com.xxx.persistence.b.object
        
    

      WEB-INF/hibernate-mapping-overrides.xml
    
  

For anyone new to the Netbeans IDE, like myself, you might find yourself perplexed by the fact that you can’t execute any substantially large projects. Netbeans relies heavily on 3rd parties for their integration with other tools, i noticed while setting up a simple SSH tunneled SVN connection. This might be a little confusing to a new developer or someone not very familiar with the two technologies.

Let’s jump into configuring this beast:

SubVersion svn+ssh://

Seeing i’m setting everything up on the new workstation my office gave me, this will be a guide for Windows 7 x64bit users.

Packages

  • SilkSVN (Client Only)
  • TortoiseSVN 1.6.9….

Both are quite easy to install with their standard Microsoft MSI bundles. The need for TortoiseSVN is two fold: 1. It is an awesome SVN client, and 2. It comes with TortoisePlink, which I had better luck with than the PuttyPlink base itself.

Now in the Netbeans IDE follow the menus ‘Team >> Subversion >> Checkout’ this will produce a dialog where you can setup your SVN repository. This example is exclusively for the svn+ssh protocol so the URL will look like: svn+ssh://servername.net/path/to/repo

The external Tunnel command will look like: TortoisePlink -l username -pw password

This assumes you have updated your windows environment variable PATH to include the bin directories of both TortoiseSVN and SilkSVN, which by default get installed to your C:\Program Files\ directory. The really nice thing about TortoisePlink is that it will not continue to ask for your password!!!! Major pain in the a** when working with the standard plink out of the box.

Maven2

This one was a little more confusing to find the solution for, but luckily it has gotten much easier thanks to the Netbeans dev team. The Netbeans team have released an update to the codehaus exec mojo SNAPSHOT that fixes the fun execution problem (https://netbeans.org/bugzilla/show_bug.cgi?id=153644).

After setup of a brand new maven 2.2.3 install, Netbeans will fail to execute any project/file that has a dependency chain over a certain length. To rectify this problem add the codaus snapshot repository to your maven 2 settings.xml as suggested in the bug report above. It will look something like:


<pluginRepositories>
<pluginRepository>
<id>s.r.c.org <name>Codehaus SNAPSHOT repository <url>http://snapshots.repository.codehaus.org <layout>default </pluginRepository>
</pluginRepositories>

Next you will need to setup your project to use the new version, luckily this is rather easy as they define the version in the execution string. Right click on your project and select properties. A dialog with a list of forms on the left should appear, select the 'Actions' button. Here you will need to go through each action that uses the exec plugin and update the Execute Goals changing the '1.1.1' string to '1.1.2-SNAPSHOT'. This data is then saved to an XML file; however, editing the XML file directly did not seem to work properly (probably because i did it while netbeans was running).

Hope this helps save some hair from getting pulled out!

Today I spent several hours wrestling with Xvfb on a fresh new Ubuntu 9.10 (Karmic Koala) installation. The initial stages of the install are very promising, simply running:


>> aptitude install xvfb

Seems to work its charm and successfully install the software package. Unfortunately, if you attempt to test the Xvfb using something like:


>> Xvfb :99 -ac

You will most likely see a long list of error messages, something like:

[dix] Could not init font path element /usr/share/fonts/X11/misc, removing from
list!
[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing
from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled,
removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled,
removing from list!
[dix] Could not init font path element /usr/share/fonts/X11/Type1, removing
from list!
[dix] Could not init font path element /usr/share/fonts/X11/100dpi, removing
from list!
[dix] Could not init font path element /usr/share/fonts/X11/75dpi, removing
from list!
sh: /usr/bin/xkbcomp: not found
(EE) Error compiling keymap (server-42)
(EE) XKB: Couldn't compile keymap
[config/dbus] couldn't take over org.x.config:
org.freedesktop.DBus.Error.AccessDenied (Connection ":1.74" is not allowed to
own the service "org.x.config.display99" due to security policies in the
configuration file)

Let us tackle this mess of an automated installation…

1. xkbcomp

Try running:

>> sudo aptitude install x11-xkb-utils

This will install the xkbcomp required.

2. Missing Font Errors (unnecessary?)

The font issues, probably, do not require fixing from a functional standpoint; nonetheless, you can install them with the following command:


>> sudo aptitude install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

3. HAL

Apparently, some of the required components of this fake X server are within the core package of the actual X server. Try installing:

>> sudo aptitude install xserver-xorg-core

4. dbus

This last fix, is not going to work for everyone. I can use it because my intended use is on a remote server configuration not requiring any packages that depend on DBUS messaging system.

>> sudo aptitude remove dbus

These four steps enabled my 9.10 Ubuntu server to run Xvfb. I tested the xvfb-run command like:

>> xvfb-run firefox

It launches the firefox browser (if installed, if not installed it just exits) and waits for you to CTRL+C cancel it.

© 2011 Technical Solutions Suffusion theme by Sayontan Sinha