[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-759) problem for mixxing setmaxresults and setlockmode

Frederic Leitenberger (JIRA) noreply at atlassian.com
Sat Aug 26 14:17:25 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-759?page=comments#action_24127 ] 

Frederic Leitenberger commented on HHH-759:
-------------------------------------------

A database-specific (Oracle only?) workaround is to limit the resultset in the query itself.
For example like this:
Query query = session.createQuery("from Table where rownum <= 1");
query.setLockMode(...);

> problem for mixxing setmaxresults and setlockmode
> -------------------------------------------------
>
>          Key: HHH-759
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-759
>      Project: Hibernate3
>         Type: Bug

>     Versions: 3.0.2
>  Environment: Client:windows2000 professional,jre1.4.2, oracle8client,eclipse3.1-RC3,hibernate-tools 3.0 alpha4a,JBossIDE1.5M1
> Server:Solaris 2.8, oracle 8.1.7
>     Reporter: johnhua
>     Priority: Minor

>
>
> there is a problem for mixxing setmaxresults and setlockmode.
> the problem is that "ORA-00904: invalid column name". 
> The error info is as the below:
> Hibernate: select * from ( select idmapp0_.RI as col_0_0_ from PCTMNGT.IDMAP_P idmapp0_ where idmapp0_.STATUS=? ) where rownum <= ? for update of idmapp0_.RI
> 14:21:54,076 DEBUG  AbstractBatcher:AbstractBatcher.java:365 - preparing statement
> 14:21:54,082 DEBUG  AbstractBatcher:AbstractBatcher.java:285 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
> 14:21:54,083 DEBUG  AbstractBatcher:AbstractBatcher.java:403 - closing statement
> 14:21:54,090  WARN  JDBCExceptionReporter:JDBCExceptionReporter.java:71 - SQL Error: 904, SQLState: 42000
> 14:21:54,091 ERROR  JDBCExceptionReporter:JDBCExceptionReporter.java:72 - ORA-00904: invalid column name
> The source code is as the below:
>     	//query an unused emid for new tone
>     	query = av_session.createQuery("select v_idmap from IdmapP as v_idmap where v_idmap.status=:v_status");
>     	query.setCharacter("v_status",EMID_STATUS.UNUSED.charValue());
>     	query.setMaxResults(1);
>     	query.setLockMode("v_idmap",LockMode.UPGRADE);
>     	it = query.iterate();
>     	if( !it.hasNext() )
>     	{
>     		tx.rollback();
>         	lv_err = "addRing::doAddRingFile: no unused EMID for new tone in idmap. toneid="+av_tone;
>         	throw new InterfaceErrException(lv_err,INTERFACE_RETCODE.SYSTEM_ERR);
>     	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list