How to retrieve a random record of DPL EntityStore of a unit test?
HelloI want to write my code integration and unit tests. I want to get something random an EntityStore? How would you do that?
If there is no direct way to get a random entry, is there a way to get an object by its position? In this way, I could determine the number and get a random input.
I write a lot of code tests of the DAO layer where I need an entry that will satisfy my foreign key relationships.
Thanks in advance,
Steven
Hi Steven,
The LPD only supports Btree (ordered key) databases. So the only access is key lookup (exact or approximate) and scanner sequentially (forward or backward).
You have probably thought about this, but one thing you can do is to get the keys of the first and the last and generates a random value between the two. Once you have generated a random key in the right range, you can approximate search of key using one of the methods entities() PrimaryIndex or SecondaryIndex.
Entities() methods have signatures that allow to specify a beginKey. If you specify the beginKey, and null for the endKey, then the first returned entity will be greater than or equal to the beginKey. This is how a rough key search is made.
-mark
Tags: Database
Similar Questions
-
Retrieve the random record from SQL and also an ORDER
I need a query that is able to get X amount of random records from a database of SQL2008, but I also want those results to then order by a field in the same table numberic, camp_priority
I have
SELECT TOP #DisplayAmount #, camp_uid, camp_title, camp_text, camp_image_type Campaigns WHERE camp_uid IN etc... etc.
then, at the bottom, I
ORDER BY newid (), camp_priority
The problem seems to be that I'm random records, but it is not ordered by the camp_priority
Anyone have any ideas?
Thank you
Mark
Hey Adam,.
I misread your original post, now I see how it was supposed to work, just posted below... got it works... works very well. If all goes well, is not to kill the CPU that this query will use a LOT... I'll just take a plu ;-) CPU
Regarding the performance of NEWID() issue, I do not have a specific link, I was just hunting around different forums etc and found a few posts that talked about performance issues and who had a command I never saw that took a percentage of files with a lot of perfomance test graphic showing it was 10 times slow the other approach.
I'll just have to see how it goes
Thanks for the help
Mark
-
How to retrieve a single record from access by program?
I need to recover a single access record. I have two columns, 'Sess' and 'Topic' in my database. I want back the Session number ('Sess') for a particular topic and post it on the front panel. I wrote the attached VI based on an example I found. This VI contains the number of the Session for the first record, but I can't understand how to identify a search for a specific record in the table. Thank you!
Do a google search for «sql tutorial» You need to learn how the SELECT statement. The general syntax is:
SELECT column_name (s)
Table_name FROM
WHERE column_name operator value -
LOBs and how to retrieve the record inserted with EMPTY_BLOb()
Hi guys
How to retrieve the records inserted with EMPTY_BLOb() instead of NULL value.
Best greetings
A.G.There must be a better way, but these work:
SELECT... from tableX where length (lob_column) = 0;
SELECT... from tableX where dbms_lob.getlength (lob_column) = 0;Concerning
Jonathan Lewis
http://jonathanlewis.WordPress.com
http://www.jlcomp.demon.co.UK"All experts it is a equal and opposite expert."
Clarke -
Lost admin password, how to retrieve the current password to change it?
I forgot my Admin password, I connect on my laptop using the scanner print finger all the time and when I try to change the password for Admin it ask the password which I do not remember. How to retrieve the current password and change it in Windows 7 Home premium?It's a laptop Acer 5738 G
You can change your current password as follows:
1. click on start.
2. type the three letters cmd in the search box.
3. press on Ctrl + Shift + Enter
4. click on "run as Administrator".
5. type the following command and press ENTER after each:
NET user "user %%nom" 123456Now the password is 123456. While dealing with accounts and passwords: having a single admin account on a PC is about the same as having a unique key for your car. What happens if you lose? He lost? Break it? A robust Windows Setup requires at least the following:
- Two admin accounts fully tested, with their passwords to record on paper.
- A password key file. Click Start / Help, then search for help on "password". Follow the instructions to create a key on your USB flash drive file so that you'll never find yourself in this uncomfortable situation.
-
How to retrieve the values of character without using single quotes
Hi all
How to retrieve the values of character without the use of single quotes. Its Possible in Oracle SQL
Please answer me...
For example
Is actual query-> Select * from employees where name like in("SCOTT", "JAMES", "ALBERT",...);
I want to--> Select * from employees where name like(SCOTT, JAMES, ALBERT...); -without the use of single quotes.
Why I need this application, I need to retrieve the records more than 200 employees in a select statement by using name in where clause.
shagarmahabubjan wrote:
Hi all
How to retrieve the values of character without the use of single quotes. Its Possible in Oracle SQL
Please answer me...
For example
Actual query is---> Select * from employees where name like in("SCOTT", "JAMES", "ALBERT",...);
I want to---> Select * from employees where name like(SCOTT, JAMES, ALBERT...); -without the use of single quotes.
Why I need this application, I need to retrieve the records more than 200 employees in a select statement by using name in where clause.
In short... you can't. The channels are channels, and SQL and PL languages dictate that the string literals are provided within single quotes.
I don't see how trying to retrieve more than 200 records of employees in the select statement means that you must get rid of the quotes.
Be clear in what you ask: Re: 2. How can I ask a question on the forums?
and take note of the FAQ link davidp provided the solution "variable IN the list.
-
Hi, I noticed on my new competitor motorola that I can record voice memos and then he said 'saved', but I can't for the life of me find out how to retrieve the memo, or where it is stored. Can anyone help?
Bernard,
Your voice memos must be store under Menu > Media Center > music ringtones & > My sons. It will be initially named something like '1122092122 a', but by pressing the Options will allow you to rename it.
-
How do I get random a table record.
Suppose there are 100 records in a table, and I want record 5th, 7th, 13th, 18th at random.
Thank youOr maybe:
select * from your_table order by dbms_random.value
or
select * from ( select rownum rn , t.* from your_table t order by dbms_random.value ) where rn in (5,7,13,18);
?:|
-
How many tracks can be recorded simultaneously in garageband version 10 for mac
How many tracks can be recorded simultaneously in garageband version 10 for mac?
You can only record 8 tracks simultaneously in garageband version 10.
-
I forgot my 4 digit number for my iphone how to retrieve or change?
I forgot my 4 digit PIN for my iphone how to retrieve or change?
Take a look:
-
Hi our friend has an old e-mail address on his old phone and e-mail account is now closed he should drop his photos and has a new email address, how he retrieve it please
Even if the e-mail account is closed the Apple is still valid. If he has forgotten the password, see: If you forgot your Apple ID - Apple Support password
What follows has instructions on how to change the e-mail address he serves his Apple ID: change your Apple - Apple Support ID
-
I renamed a folder and it disappeared. How to retrieve it?
Please forgive this if redundant post, I received an error message when I posted this.
I renamed a folder in Thunderbird, but it disappeared immediately. I opened all closed files to ensure it had not moved, but it does not appear on the left side of the screen. Any ideas where he might have or how to retrieve the contents of the folder?
Thanks in advance.
I have marked you post as solved, but could you share how. We get a lot of very similar questions. Your experience can help me by informing the next person.
-
I deleted my app podcast how to retrieve it?
I deleted my app podcast how to retrieve it?
If you have an iTunes backup - you may be able to restore back to the top and the app will be restored with her
Or
You can download it from the app store
-
Replacement of Firefox 3.6.16 containing my history, bookmarks etc to version 4.0, I find that it does not open on my Mac Power PC G4 OS 10.4.11. Is there is a compatibility issue and how to retrieve version 3.6 with my favorites etc.
Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third part of Firefox 4 version that works under OS X 10.4/10.5 and PPC Macs, for details, see http://www.floodgap.com/software/tenfourfox
If you prefer, you can get the latest version of Firefox 3.6 http://www.mozilla.com/en-US/firefox/all-older.html
When you install one of the above it will use your existing bookmarks, etc.
-
How to retrieve text messages deleted from the Iphone 5
How to retrieve deleted messages of I Phone 5?
Unfortunately there is no way to recover messages text deleted from an iPhone, unless you had a previous backup in iTunes before delete you messages. Restore this backup would be the only way to recover deleted messages. Once they are deleted they are gone forever, unlike the Photos that you can pick up if accidentally deleted by restoring their from the album "recently deleted".
Maybe you are looking for
-
Cannot restore the files from hard drive damaged in disk utility
Questions 1. can I save my files/fix this problem without having to restore via disk utility? 2. What am I doing wrong / I can do to restore correctly on an external hard drive via disk utility? Background Last week when I turned my MacBook Pro 2012
-
When I receive a document attached (Word or OpenOffice), I click on it. I get a Norton Antivirus window that says it is clear and I click on the yellow button to download it. Nothing happens. 1. I don't get windows that asked to open? or save? 2. the
-
Problem scanning C310 hp photosmart premium
I have a wireless hp printer C310 photosmart premium and suddenly it will scan is no longer in the Panel, the message said 'try scanning the computer' but I can't do it either.
-
Manager Microsoft Access in the auditing keeps popping up for a password when I try to access any program - how to turn off this feature - where is it located?
-
Download NVIDIA graphic driver
I tried to download the latest graphics driver for my HP Pavilion 14-n059tx laptop. The problem I keep having is that when I press the button download loading wheel starts in the tab, but nothing is really happening. I tried this on the page of searc