Author: snjeza
Date: 2008-06-30 10:58:58 -0400 (Mon, 30 Jun 2008)
New Revision: 9019
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java
Log:
JBIDE-2220 JBoss BIRT Integration - Adding parameters to the BIRT Hibernate ODA data set
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java
===================================================================
---
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java 2008-06-30
14:58:52 UTC (rev 9018)
+++
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java 2008-06-30
14:58:58 UTC (rev 9019)
@@ -1,10 +1,12 @@
package org.jboss.tools.birt.oda.impl;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
+import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.hibernate.EntityMode;
@@ -12,6 +14,8 @@
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.engine.query.HQLQueryPlan;
+import org.hibernate.impl.SessionFactoryImpl;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.type.Type;
import org.jboss.tools.birt.oda.IOdaFactory;
@@ -42,6 +46,11 @@
public HibernateResultSetMetaData prepare(String queryText) throws OdaException {
this.queryText = queryText;
+ return parseQuery();
+ }
+
+ private HibernateResultSetMetaData parseQuery()
+ throws OdaException {
List arColsType = new ArrayList();
List arCols = new ArrayList();
List arColClass = new ArrayList();
@@ -152,6 +161,19 @@
try {
session = getSessionFactory().openSession();
Query q = session.createQuery(queryText);
+ HibernateParameterMetaData parameterMetaData = (HibernateParameterMetaData)
query.getParameterMetaData();
+ List<Parameter> parameters = parameterMetaData.getParameters();
+ int position=0;
+ SessionFactoryImpl sfimpl = (SessionFactoryImpl) sessionFactory; // hack - to get to
the actual queries..
+ HQLQueryPlan plan = new HQLQueryPlan(queryText, false, Collections.EMPTY_MAP,
sfimpl);
+ int pCount = plan.getParameterMetadata().getOrdinalParameterCount();
+ if (pCount > 0) {
+ for(Parameter parameter:parameters) {
+ q.setParameter(position++, parameter.getValue(), parameter.getHibernateType());
+ if (position >= pCount)
+ break;
+ }
+ }
result = q.list();
iterator = result.iterator();
this.queryReturnTypes = q.getReturnTypes();
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java
===================================================================
---
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java 2008-06-30
14:58:52 UTC (rev 9018)
+++
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java 2008-06-30
14:58:58 UTC (rev 9019)
@@ -12,6 +12,7 @@
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.List;
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.IQuery;
@@ -23,295 +24,336 @@
/**
* Implementation class of IQuery for an ODA runtime driver.
*
- * @author snjeza
+ * @author snjeza
*/
-public class HibernateOdaQuery implements IQuery
-{
+public class HibernateOdaQuery implements IQuery {
private HibernateConnection connection;
private HibernateResultSetMetaData resultSetMetaData;
-
+ private HibernateParameterMetaData parameterMetaData = new
HibernateParameterMetaData();
+
public HibernateOdaQuery(HibernateConnection connection) {
this.connection = connection;
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
*/
public void prepare(String queryText) throws OdaException {
- this.resultSetMetaData = getConnection().getOdaSessionFactory().prepare(queryText);
+ this.resultSetMetaData = getConnection().getOdaSessionFactory()
+ .prepare(queryText);
}
-
+
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang.Object)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang
+ * .Object)
*/
- public void setAppContext( Object context ) throws OdaException
- {
- // do nothing; assumes no support for pass-through context
+ public void setAppContext(Object context) throws OdaException {
+ // do nothing; assumes no support for pass-through context
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#close()
*/
- public void close() throws OdaException
- {
- // TODO Auto-generated method stub
+ public void close() throws OdaException {
+ // TODO Auto-generated method stub
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMetaData()
*/
- public IResultSetMetaData getMetaData() throws OdaException
- {
+ public IResultSetMetaData getMetaData() throws OdaException {
return this.resultSetMetaData;
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#executeQuery()
*/
- public IResultSet executeQuery() throws OdaException
- {
- try {
- return new HibernateResultSet(this);
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- }
+ public IResultSet executeQuery() throws OdaException {
+ try {
+ return new HibernateResultSet(this);
+ } catch (Exception e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String,
java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String
+ * , java.lang.String)
*/
- public void setProperty( String name, String value ) throws OdaException
- {
+ public void setProperty(String name, String value) throws OdaException {
// do nothing; assumes no data set query property
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#setMaxRows(int)
*/
- public void setMaxRows( int max ) throws OdaException
- {
- getConnection().getOdaSessionFactory().setMaxRows(max);
+ public void setMaxRows(int max) throws OdaException {
+ getConnection().getOdaSessionFactory().setMaxRows(max);
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMaxRows()
*/
- public int getMaxRows() throws OdaException
- {
+ public int getMaxRows() throws OdaException {
return getConnection().getOdaSessionFactory().getMaxRows();
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#clearInParameters()
*/
- public void clearInParameters() throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void clearInParameters() throws OdaException {
+ parameterMetaData.getParameters().clear();
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String, int)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String,
+ * int)
*/
- public void setInt( String parameterName, int value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setInt(String parameterName, int value) throws OdaException {
+ setParameter(parameterName, Parameter.IntegerType, value);
}
+
+ private void setParameter(String parameterName,int type,Object value) {
+ Parameter parameter = getParameter(parameterName);
+ if (parameter == null) {
+ parameter = new Parameter(type, parameterName,
+ value);
+ parameterMetaData.getParameters().add(parameter);
+ } else {
+ parameter.setValue(value);
+ parameter.setType(type);
+ }
+ }
+ private Parameter getParameter(String parameterName) {
+ if (parameterName == null)
+ return null;
+ List<Parameter> parameters = parameterMetaData.getParameters();
+ for (Parameter parameter : parameters) {
+ if (parameterName.equals(parameter.getName())) {
+ return parameter;
+ }
+ }
+ return null;
+ }
+
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(int, int)
*/
- public void setInt( int parameterId, int value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setInt(int parameterId, int value) throws OdaException {
+ setParameter(parameterId, Parameter.IntegerType, value);
}
+
+ private void setParameter(int parameterId,int type,Object value) {
+ List<Parameter> parameters = parameterMetaData.getParameters();
+ String parameterName = "parameter" + parameterId;
+ if (parameters.size() < parameterId) {
+ Parameter parameter = new Parameter(type, parameterName,
+ value);
+ parameterMetaData.getParameters().add(parameter);
+ } else {
+ Parameter parameter = parameterMetaData.getParameters().get(parameterId-1);
+ parameter.setValue(value);
+ parameter.setType(type);
+ }
+ }
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String,
double)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String,
+ * double)
*/
- public void setDouble( String parameterName, double value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setDouble(String parameterName, double value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.DoubleType, new Double(value));
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(int, double)
*/
- public void setDouble( int parameterId, double value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setDouble(int parameterId, double value) throws OdaException {
+ setParameter(parameterId, Parameter.DoubleType, new Double(value));
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang.String,
java.math.BigDecimal)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang
+ * .String, java.math.BigDecimal)
*/
- public void setBigDecimal( String parameterName, BigDecimal value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setBigDecimal(String parameterName, BigDecimal value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.BigDecimalType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int,
java.math.BigDecimal)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int,
+ * java.math.BigDecimal)
*/
- public void setBigDecimal( int parameterId, BigDecimal value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setBigDecimal(int parameterId, BigDecimal value)
+ throws OdaException {
+ setParameter(parameterId, Parameter.BigDecimalType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String,
java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String,
+ * java.lang.String)
*/
- public void setString( String parameterName, String value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setString(String parameterName, String value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.StringType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int, java.lang.String)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int,
+ * java.lang.String)
*/
- public void setString( int parameterId, String value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setString(int parameterId, String value) throws OdaException {
+ setParameter(parameterId, Parameter.StringType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String,
java.sql.Date)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String,
+ * java.sql.Date)
*/
- public void setDate( String parameterName, Date value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setDate(String parameterName, Date value) throws OdaException {
+ setParameter(parameterName, Parameter.DateType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int, java.sql.Date)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int,
+ * java.sql.Date)
*/
- public void setDate( int parameterId, Date value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setDate(int parameterId, Date value) throws OdaException {
+ setParameter(parameterId, Parameter.DateType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String,
java.sql.Time)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String,
+ * java.sql.Time)
*/
- public void setTime( String parameterName, Time value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setTime(String parameterName, Time value) throws OdaException {
+ setParameter(parameterName, Parameter.TimeType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int, java.sql.Time)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int,
+ * java.sql.Time)
*/
- public void setTime( int parameterId, Time value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setTime(int parameterId, Time value) throws OdaException {
+ setParameter(parameterId, Parameter.TimeType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.String,
java.sql.Timestamp)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.
+ * String, java.sql.Timestamp)
*/
- public void setTimestamp( String parameterName, Timestamp value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setTimestamp(String parameterName, Timestamp value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.TimestampType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int,
java.sql.Timestamp)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int,
+ * java.sql.Timestamp)
*/
- public void setTimestamp( int parameterId, Timestamp value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setTimestamp(int parameterId, Timestamp value)
+ throws OdaException {
+ setParameter(parameterId, Parameter.TimestampType, value);
}
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(java.lang.String,
boolean)
- */
- public void setBoolean( String parameterName, boolean value )
- throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(java.lang.String
+ * , boolean)
+ */
+ public void setBoolean(String parameterName, boolean value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.BooleanType, new Boolean(value));
+ }
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(int, boolean)
- */
- public void setBoolean( int parameterId, boolean value )
- throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(java.lang.String)
- */
- public void setNull( String parameterName ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(int,
+ * boolean)
+ */
+ public void setBoolean(int parameterId, boolean value) throws OdaException {
+ setParameter(parameterId, Parameter.BooleanType, new Boolean(value));
+ }
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(int)
- */
- public void setNull( int parameterId ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setNull(java.lang.String)
+ */
+ public void setNull(String parameterName) throws OdaException {
+ Parameter parameter = getParameter(parameterName);
+ if (parameter != null) {
+ parameter.setValue(null);
+ }
+ }
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang.String)
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(int)
*/
- public int findInParameter( String parameterName ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setNull(int parameterId) throws OdaException {
+ Parameter parameter = parameterMetaData.getParameters().get(parameterId);
+ if (parameter != null) {
+ parameter.setValue(null);
+ }
+ }
+
+ /*
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang
+ * .String)
+ */
+ public int findInParameter(String parameterName) throws OdaException {
+ if (parameterName == null)
+ return 0;
+ for(Parameter parameter:parameterMetaData.getParameters()) {
+ if (parameterName.equals(parameter.getName()))
+ return parameterMetaData.getParameters().indexOf(parameter);
+ }
return 0;
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getParameterMetaData()
*/
- public IParameterMetaData getParameterMetaData() throws OdaException
- {
- /* TODO Auto-generated method stub
- * Replace with implementation to return an instance
- * based on this prepared query.
- */
- return new HibernateParameterMetaData();
+ public IParameterMetaData getParameterMetaData() throws OdaException {
+ return parameterMetaData;
}
/*
- * @see
org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse.datatools.connectivity.oda.SortSpec)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse
+ * .datatools.connectivity.oda.SortSpec)
*/
- public void setSortSpec( SortSpec sortBy ) throws OdaException
- {
- // TODO Auto-generated method stub
+ public void setSortSpec(SortSpec sortBy) throws OdaException {
+ // TODO Auto-generated method stub
// only applies to sorting, assumes not supported
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException();
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getSortSpec()
*/
- public SortSpec getSortSpec() throws OdaException
- {
- // TODO Auto-generated method stub
+ public SortSpec getSortSpec() throws OdaException {
+ // TODO Auto-generated method stub
// only applies to sorting
return null;
}
@@ -319,5 +361,5 @@
public HibernateConnection getConnection() {
return connection;
}
-
+
}
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java
===================================================================
---
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java 2008-06-30
14:58:52 UTC (rev 9018)
+++
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java 2008-06-30
14:58:58 UTC (rev 9019)
@@ -9,6 +9,9 @@
package org.jboss.tools.birt.oda.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
@@ -20,12 +23,14 @@
public class HibernateParameterMetaData implements IParameterMetaData
{
+ private List<Parameter> parameters = new ArrayList<Parameter>();
+
/*
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterCount()
*/
public int getParameterCount() throws OdaException
{
- return 0;
+ return parameters.size();
}
/*
@@ -41,7 +46,11 @@
*/
public String getParameterName( int param ) throws OdaException
{
- return null; // name is not available
+ if (getParameterCount() > param) {
+ return null;
+ }
+ Parameter parameter = parameters.get(param);
+ return parameter.getName();
}
/*
@@ -49,7 +58,11 @@
*/
public int getParameterType( int param ) throws OdaException
{
- return java.sql.Types.CHAR; // as defined in data set extension manifest
+ if (getParameterCount() > param) {
+ return -1;
+ }
+ Parameter parameter = parameters.get(param);
+ return parameter.getType();
}
/*
@@ -85,4 +98,8 @@
return IParameterMetaData.parameterNullableUnknown;
}
+ public List<Parameter> getParameters() {
+ return parameters;
+ }
+
}
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java
===================================================================
---
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java
(rev 0)
+++
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java 2008-06-30
14:58:58 UTC (rev 9019)
@@ -0,0 +1,93 @@
+package org.jboss.tools.birt.oda.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.Hibernate;
+import org.hibernate.type.Type;
+
+public class Parameter {
+ public static int StringType = 1;
+ public static int IntegerType = 4;
+ public static int DoubleType = 8;
+ public static int BigDecimalType = 3;
+ public static int DateType = 91;
+ public static int TimeType = 92;
+ public static int TimestampType = 93;
+ public static int BooleanType = 16;
+
+ private String name;
+ private int type;
+ private String typeName;
+ private Object value;
+ private static Map<Integer,Type>hibernateTypes = new
HashMap<Integer,Type>();
+
+ static {
+ hibernateTypes.put(StringType, Hibernate.STRING);
+ hibernateTypes.put(IntegerType, Hibernate.INTEGER);
+ hibernateTypes.put(DoubleType, Hibernate.DOUBLE);
+ hibernateTypes.put(BigDecimalType, Hibernate.BIG_DECIMAL);
+ hibernateTypes.put(DateType, Hibernate.DATE);
+ hibernateTypes.put(TimeType, Hibernate.TIME);
+ hibernateTypes.put(TimestampType, Hibernate.TIMESTAMP);
+ hibernateTypes.put(BooleanType, Hibernate.BOOLEAN);
+ }
+
+ public Parameter(int type, String name, Object value) {
+ this.type = type;
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public int getType() {
+ return type;
+ }
+ public void setType(int type) {
+ this.type = type;
+ }
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Parameter other = (Parameter) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ public Type getHibernateType() {
+ return hibernateTypes.get(type);
+ }
+}