Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg
In directory sc8-pr-cvs1:/tmp/cvs-serv31825/cirrus/hibernate/odmg
Modified Files:
OQLQuery.java
Log Message:
Query.setEntity(), etc, now aware of proxies (also improved hueristics for guessing types)
Index: OQLQuery.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/odmg/OQLQuery.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** OQLQuery.java 26 Nov 2002 03:35:43 -0000 1.5
--- OQLQuery.java 12 Mar 2003 12:40:52 -0000 1.6
***************
*** 7,11 ****
public OQLQuery(Database db) {
this.tx = db.currentTransaction();
}
/**
* Instantiate an <tt>OQLQuery</tt> for the given transaction.
*/
public OQLQuery(Transaction tx) {
this.tx = tx;
}
/**
* Instantiate an <tt>OQLQuery</tt> for the current transaction.
*/
public OQLQuery() {
this.tx = (Transaction) Implementation.getInstance().currentTransaction();
}
/**
* Get the underlying Hibernate <tt>Query</tt>.
*/
public Query getQuery() {
return query;
}
/**
* Set the HIbernate query string. Scalar return values are not supported.
* @see org.odmg.OQLQuery#create(String)
*/
public void create(String queryString) throws QueryInvalidException {
//TODO: the right exception
try {
this.query = tx.getSession().createQuery(queryString);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
! /**
* Bind a value to the next <tt>?</tt> style parameter.
* @see org.odmg.OQLQuery#bind(Object)
*/
public void bind(Object parameter) throws QueryParameterCountInvalidException, QueryParameterTypeInvalidException {
//TODO: the right exception
try {
query.setParameter(param++, parameter);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
/**
* Get the query results as a collection.
* @see org.odmg.OQLQuery#execute()
*/
public Object execute() throws QueryException {
//TODO: how are results meant to be returned in ODMG?
try {
return query.list();
}
catch (SQLException sqle) {
throw new QueryException( sqle.getMessage() );
}
catch (HibernateException he) {
throw new QueryException( he.getMessage() );
}
}
}
--- 7,11 ----
public OQLQuery(Database db) {
this.tx = db.currentTransaction();
}
/**
* Instantiate an <tt>OQLQuery</tt> for the given transaction.
*/
public OQLQuery(Transaction tx) {
this.tx = tx;
}
/**
* Instantiate an <tt>OQLQuery</tt> for the current transaction.
*/
public OQLQuery() {
this.tx = (Transaction) Implementation.getInstance().currentTransaction();
}
/**
* Get the underlying Hibernate <tt>Query</tt>.
*/
public Query getQuery() {
return query;
}
/**
* Set the HIbernate query string. Scalar return values are not supported.
* @see org.odmg.OQLQuery#create(String)
*/
public void create(String queryString) throws QueryInvalidException {
//TODO: the right exception
try {
this.query = tx.getSession().createQuery(queryString);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
! /**
* Bind a value to the next <tt>?</tt> style parameter.
* @see org.odmg.OQLQuery#bind(Object)
*/
public void bind(Object parameter) throws QueryParameterCountInvalidException, QueryParameterTypeInvalidException {
//TODO: the right exception
try {
query.setParameter(param++, parameter);
}
catch (Exception e) {
throw new ODMGRuntimeException( e.getMessage() );
}
}
/**
* Get the query results as a collection.
* @see org.odmg.OQLQuery#execute()
*/
public Object execute() throws QueryException {
//TODO: how are results meant to be returned in ODMG?
try {
return query.list();
}
catch (SQLException sqle) {
throw new QueryException( sqle.getMessage() );
}
catch (HibernateException he) {
throw new QueryException( he.getMessage() );
}
}
}
|