Supporting multiple databases in one codebase

2 messages Options
Embed this post
Permalink
Ronald Lawrence

Supporting multiple databases in one codebase

Reply Threaded More More options
Print post
Permalink
Karel,

Thanks to your hint about the undocumented config file in my last thread, I looked around in the code and also found the "hibernate.spatial.dialect" property. This allows me to run junit tests against postgresql or oracle and seems to allow me to generate correct DDL with my SchemaUpdate invocations (more on this for oracle in another post).

To do this, I setup the dialect in the @Before method like this:

   System.setProperty( "hibernate.spatial.dialect", org.hibernatespatial.postgis.PostgisDialect.class.getCanonicalName() );

This will fail if any reference (direct or indirect) to HBSpatialExtension happens before the test run. I first had an assert against the configuration here, but had to remove it because just having the reference caused the static block to execute before my code could set the property.

Would it be better to have this code explicitly invoked in the way that the "config()" method in the same class is invoked?

Thanks,
Ron

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: Supporting multiple databases in one codebase

Reply Threaded More More options
Print post
Permalink
Hi Ron,

You can set this property from the command-line (or startup-script)  
bij passing the -D option to the java jre.  Like

 > java -
Dhibernate.spatial.dialect=org.hibernatespatial.org.PostgisDialect

Regards,

Karel

On 08 May 2009, at 22:22, Ron Lawrence wrote:

> Karel,
>
> Thanks to your hint about the undocumented config file in my last  
> thread, I looked around in the code and also found the  
> "hibernate.spatial.dialect" property. This allows me to run junit  
> tests against postgresql or oracle and seems to allow me to  
> generate correct DDL with my SchemaUpdate invocations (more on this  
> for oracle in another post).
>
> To do this, I setup the dialect in the @Before method like this:
>
>    System.setProperty( "hibernate.spatial.dialect",  
> org.hibernatespatial.postgis.PostgisDialect.class.getCanonicalName
> () );
>
> This will fail if any reference (direct or indirect) to  
> HBSpatialExtension happens before the test run. I first had an  
> assert against the configuration here, but had to remove it because  
> just having the reference caused the static block to execute before  
> my code could set the property.
>
> Would it be better to have this code explicitly invoked in the way  
> that the "config()" method in the same class is invoked?
>
> Thanks,
> Ron
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/ 
> hibernatespatial-users


_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users