jquery

gist JS

Monday, December 11, 2006

X60 Tablet Memory Prices


  • 512 MB PC2-5300 DDR2 667MHz Memory (1 DIMM) [add $0.00]

  • 1 GB PC2-5300 DDR2 667MHz Memory (2 DIMM) Memory Sale! Additional 512MB memory is free (You save: $80).

  • 1 GB PC2-5300 DDR2 667MHz Memory (1 DIMM) [add $90.00]

  • 1.5 GB PC2-5300 DDR2 667MHz Memory (2 DIMM) [add $99.00] [Lenovo recommended]

  • 2 GB PC2-4200 DDR2 533MHz Memory (1 DIMM) [add $820.00]


Does this make sense to anyone? This is just bizarre right?

Wednesday, December 06, 2006

Updated Spring Configuration

Here's an updated version of the HostPrecedingPropertyPlaceholderConfigurer that I introduced here.

This version makes for cleaner property files since you don't need to duplicate everything for each HOST, just the properties that are different.

The goal of this class is to be able to deploy your spring project to multiple hosts without needed to reconfigure / edit any properties files. This method makes it much easier to keep properties files in svn or cvs as well, because when Bob makes a change to the testDB server properties, he won't blow away your DB username etc when you checkout his changes.



package com.aavu.server.util;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;


/**
* HostPrecedingPropertyPlaceholderConfigurer
*
* Extends PropertyPlaceholderConfigurer to insert $hostname.property if
* the property name starts with HOST
* sample properties file:
*
* jdbc.user=live_user
* server.jdbc.url=jdbc:postgresql://db.host.com:5432/db
* server.magic.file.location=/var/magic_file
*
* jdbc.user=devel_user
* devel.jdbc.url=jdbc:postgresql://devel-db.host.com:5432/db
* devel.magic.file.location=c:\\var\magic_file
*
* my.property=a property referenced through a method besides
* HostPrecedingPropertyPlaceholderConfigurer
*
* <bean id="propertyConfigurer"
* class="com.util.spring.HostPrecedingPropertyPlaceholderConfigurer">
* <property name="location" value="classpath:config.properties" />
* </bean>
*
* <bean id="dataSource"
* class="com.mchange.v2.c3p0.ComboPooledDataSource"
* destroy-method="close">
* <property name="driverClass" value="${jdbc.driverClass}" />
* <property name="jdbcUrl" value="${HOST.jdbc.url}" /><!--Do a host lookup!-->
* <property name="user" value="${jdbc.user}" />
* <property name="password" value="${jdbc.password}" />
* </bean>
*
*
* @author Jeff Dwyer (blog) http://jdwyah.blogspot.com
*
*/
public class HostPrecedingPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {

private static Logger log = Logger.getLogger(HostPrecedingPropertyPlaceholderConfigurer.class);

protected String resolvePlaceholder(String placeholder, Properties props) {

try {

if(placeholder.startsWith("HOST.")){
log.debug("Host: "+InetAddress.getLocalHost().getHostName()+" for property "+placeholder);
String replace = placeholder.replaceFirst("HOST", InetAddress.getLocalHost().getHostName());
return props.getProperty(replace);
}else{
log.debug("reg");
return props.getProperty(placeholder);
}
} catch (UnknownHostException e) {
log.warn(e);
return null;
}
}
}

Friday, December 01, 2006

Changing cats into dogs

Hibernate Modifying subclass's discriminator value on update

Well, despite the naysayers above I've succeeded in doing the unnatural and have changed the type of a polymorphic Hibernate class.

Dog changeCatToDog(Cat cat){
int res = (Integer) getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session sess) throws Exception {
String hqlUpdate = "update Animal set discriminator = 'dog' where animal_id = :id";
int updatedEntities = sess.createQuery( hqlUpdate )
.setLong( "id", cat.getId() )
.executeUpdate();
return updatedEntities;
}});

getHibernateTemplate().evict(t);

return (Dog) getHibernateTemplate().get(Dog.class, cat.getId());
}