-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: is there a dialect availablke for foxpro,clipeer and Dbase
PostPosted: Wed Apr 13, 2005 6:50 am 
Newbie

Joined: Wed Apr 13, 2005 6:46 am
Posts: 2
Hi there,

Can anybody help me in finding a dialect for Foxpro/Clipper/DbaseIII
database that can be used with hibernate?

Any other solutions also welcome for the above datyabases.


Top
 Profile  
 
 Post subject: foxpro dialect
PostPosted: Wed Apr 13, 2005 10:22 am 
Newbie

Joined: Fri Mar 05, 2004 8:55 am
Posts: 19
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.
@+


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 2:17 am 
Newbie

Joined: Wed Apr 13, 2005 6:46 am
Posts: 2
Thanks voilo. Can I use the same for clipper and dbase iii?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 9:06 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Hi,

is it possible to do the same with nhibernate (for .NET) ? I cannot find the dll in the nhibernate 1.2 package. Is it possible to download them somewhere ?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.