Hibernate, how random took out a data?

Hibernate, how random took out a data?
I use Oracle, the direct use of the SQL statement in Oracle, top or limit, can, however, put down the hibernate SQL statement.
Solving?

Started by Kevin at November 24, 2016 - 1:43 PM

I use 12C? Oracle in how to use top? Can you put SQL posted?

Oracle is a random function in dbms_random

Posted by Ziv at November 29, 2016 - 1:47 PM

select * from usm_item t where t.item_bank_child_id= 4 and t.item_type=1 order by RAND() limit 1;


This is the SQL statement

Posted by Kevin at December 13, 2016 - 2:26 PM

In the implementation of hibernate, limit not recognized

Posted by Kevin at December 23, 2016 - 2:57 PM

Limit is a MySQL page using Oracle, using top+ sub query.

You can have a look this article

Posted by Amber at January 02, 2017 - 3:02 PM

Feel shy, just wrong, SQLServer is top. Oracle is a rownum+ query.

Posted by Amber at January 04, 2017 - 3:07 PM



Limit does not support Oracle

You need to switch the Hibernate dialect.

Posted by Jenny at January 05, 2017 - 3:16 PM

The specific usage.?

Posted by Kevin at January 06, 2017 - 3:46 PM

You can have a look this article

Posted by Amber at January 12, 2017 - 4:43 PM

I wrote a, but when I tested a little problem, sometimes not recorded, sometimes returned several records, I could not find the reasons in where, you help me look at
select * from (select rownum rn, e.* from emp e)t where t.rn=round(dbms_random.value(1,(select count(*) from emp)))

Posted by Warren at January 15, 2017 - 4:55 PM