Created
October 13, 2015 14:48
-
-
Save hugithordarson/f04fd044b59c4ce60aa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nb; | |
import java.util.List; | |
import org.apache.cayenne.access.translator.ejbql.EJBQLConditionTranslator; | |
import org.apache.cayenne.access.translator.ejbql.EJBQLTranslationContext; | |
import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory; | |
import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory; | |
import org.apache.cayenne.access.types.ExtendedType; | |
import org.apache.cayenne.access.types.ExtendedTypeFactory; | |
import org.apache.cayenne.configuration.RuntimeProperties; | |
import org.apache.cayenne.dba.JdbcAdapter; | |
import org.apache.cayenne.di.Inject; | |
import org.apache.cayenne.ejbql.EJBQLExpression; | |
import org.apache.cayenne.ejbql.EJBQLExpressionVisitor; | |
import org.apache.cayenne.resource.ResourceLocator; | |
public class InformixAdapter extends JdbcAdapter { | |
public InformixAdapter( @Inject RuntimeProperties runtimeProperties, @Inject( "cayenne.server.default_types" ) List<ExtendedType> defaultExtendedTypes, @Inject( "cayenne.server.user_types" ) List<ExtendedType> userExtendedTypes, @Inject( "cayenne.server.type_factories" ) List<ExtendedTypeFactory> extendedTypeFactories, @Inject ResourceLocator resourceLocator) { | |
super( runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories, resourceLocator ); | |
} | |
@Override | |
public EJBQLTranslatorFactory getEjbqlTranslatorFactory() { | |
return new InformixEJBQLTranslatorFactory(); | |
} | |
private static class InformixEJBQLTranslatorFactory extends JdbcEJBQLTranslatorFactory { | |
@Override | |
public EJBQLExpressionVisitor getConditionTranslator( EJBQLTranslationContext context ) { | |
return new InformixEJBQLConditionTranslator( context ); | |
} | |
} | |
private static class InformixEJBQLConditionTranslator extends EJBQLConditionTranslator { | |
protected InformixEJBQLConditionTranslator( EJBQLTranslationContext context ) { | |
super( context ); | |
} | |
@Override | |
public boolean visitUpper( EJBQLExpression expression, int finishedChildIndex ) { | |
if( finishedChildIndex < 0 ) { | |
context.append( " UPPER(" ); | |
} | |
else if( finishedChildIndex + 1 == expression.getChildrenCount() ) { | |
context.append( ")" ); | |
} | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment