Trying to override Oracle10gDialect and adding in over and partition functions. I read on hibernate.org about how to override the dialect. I am using Hibernate 4.1.7.Final and cannot upgrade. I implemented it as specified, however i am getting this error.
15:21:21,353 WARN SqlExceptionHelper:143 - SQL Error: 907, SQLState: 42000
[10/8/13 15:21:21:354 CDT] 00000021 SystemOut O ORA-00907: missing right parenthesis
[10/8/13 15:21:21:354 CDT] 00000021 SystemOut O 15:21:21,354 ERROR SqlExceptionHelper:144 - ORA-00907: missing right parenthesis
Here is the class that i build:
package com.edmann.util;
import org.apache.log4j.Logger;
import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.dialect.function.StandardSQLFunction;
/**
* Because i need some analytic functions i am going to extend the
* oracle10gDialect so i can register my functions i want to use.
*
* @author Edward Mann
*
*/
public class Oracle10gDialectExtended extends Oracle10gDialect {
// get log4j handler
private static final Logger LOG = Logger
.getLogger(Oracle10gDialectExtended.class);
/**
* Override registerFunctions so that we can register the ones we want to
* use, then we will call the registerFunctions from the parent class.
*
*/
@Override
protected void registerFunctions() {
LOG.info("Trying to register custom functions");
registerFunction("over", new StandardSQLFunction("over"));
registerFunction("partition", new StandardSQLFunction("partition"));
super.registerFunctions();
}
}
Here is my entry in my hbm.xml file:
<property name="rank" type="integer" formula="(ROW_NUMBER() over(partition by ENTRY_NUMBER ORDER BY ENTRY_DATE DESC))"/>
The challenge i am having is keeping hibernate from adding this_. to the partition. In the hibernate forum thread that i linked to, the last entry was a person having the same issue. I am not sure if this is even possible with Hibernate Criteria.
Thanks for any help.
Update: I found my answer i added
registerKeyword("partition");
To my Oracle10gDialectExtended class in the registerFunctions method and it now works as expected.