with
hibernate 2.1 :
-use the sun.jdbc.odbc.JdbcOdbcDriver
-option hibernate.jdbc.batch_size =0
-option hibernate.jdbc.use_scrollable_resultsets=false
-new dialect :
-redefine FOXPRO IF function:
Code:
public class FoxProCaseFragment extends CaseFragment {
public String toFragmentString() {
StringBuffer buf = new StringBuffer( cases.size() * 15 + 10 );
StringBuffer buf2= new StringBuffer( cases.size() );
Iterator iter = cases.entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry me = (Map.Entry) iter.next();
buf.append(" iif( NOT ISNULL(")
.append( me.getKey() )
.append(") , ")
.append( me.getValue() )
.append(", ");
buf2.append(")");
}
buf.append(".NULL.");
buf.append(buf2);
if (returnColumnName!=null) {
buf.append(" as ")
.append(returnColumnName);
}
return buf.toString();
}
}
-new dialect :
Code:
public class FoxProDialect extends GenericDialect {
public boolean supportsForUpdate() {
return false;
}
public CaseFragment createCaseFragment() {
return new FoxProCaseFragment();
}
}
-last problem with varchar type and blank (interceptor):
Code:
public class FoxProInterceptor implements Interceptor, Serializable {
static protected Log log = LogFactory.getLog(FoxProInterceptor.class);
public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
return null;
}
public Object instantiate(Class clazz, Serializable id) throws CallbackException {
return null;
}
public Boolean isUnsaved(Object entity) {
return null;
}
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException {
}
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
throws CallbackException {
return false;
}
public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException {
if(types!=null)
for (int i = 0; i < types.length; i++) {
if(types[i] instanceof StringType){
if(state[i] !=null ){
state[i] =""+state[i].toString().trim();
}
}
}
return false;
}
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException {
return false;
}
public void postFlush(Iterator entities) throws CallbackException {
}
public void preFlush(Iterator entities) throws CallbackException {
}
}
-add interceptor in your config :
Code:
hibernateconf.setInterceptor(new FoxProInterceptor());
sessionFactory = hibernateconf.buildSessionFactory();
voila.
@+