Autodiscover scalar types in native-sql

Description

the ejb3 spec states that it should be possible to do something like:

s.createSQLQuery("select emp.regionCode as regioncode, emp.empid as empid from employment emp").addScalar("regioncode").addScalar("empid").list()

note the missing type information.

Furthermore executeUpdate() might also be relevant for ejb3

Environment

None

Activity

Show:
Steve Ebersole
December 10, 2005, 12:26 AM

The rest of this should be fine to apply.

As for some of your TODO questions:
1) auto-discovery should be fine for scroll; should be fine for iterate() also since we are only talking about scalar select expressions here.
2) callable is definitely problematic for iterate(); I think it would not work for scroll either in terms of actually getting the server to return us a scrollable cursor from a stored-proc (but that's just a gut feeling, I may be wrong here)

Steve Ebersole
December 10, 2005, 12:27 AM

SessionImpl:
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
checkTransactionSynchStatus();
queryParameters.validateParameters();
HQLQueryPlan plan = getHQLQueryPlan( query, false );

boolean success = false;
int result = 0;
try {
result = plan.performExecuteUpdate( queryParameters, this );
success = true;
}
finally {
afterOperation(success);
}
return result;
}

So, not sure how that would work...

Max Rydahl Andersen
December 12, 2005, 10:54 AM

> 1) auto-discovery should be fine for scroll; should be fine for iterate() also since we are only talking about scalar select expressions here.

not an issue since iterate() is not supported for native sql queries (yet), and remember that scalar can be mixed with entities so if we add it at some point we should ensure it only works it for pure scalar.

> 2) callable is definitely problematic for iterate(); I think it would not work for scroll either in terms of actually getting the server to return us a > scrollable cursor from a stored-proc (but that's just a gut feeling, I may be wrong here)

i'm now throwing an exception if callable=true and iterate().
scroll() is still attempted since it might work on some dbs.

i have added some basic default type guessing to Dialect and removed the executeUpdate in the sql stuff.

Max Rydahl Andersen
December 12, 2005, 10:57 AM

updated comment to reflect what it actually does

Max Rydahl Andersen
December 12, 2005, 10:58 AM

done

Fixed

Assignee

Max Rydahl Andersen

Reporter

Max Rydahl Andersen

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Critical
Configure