Queries inside Entity list - JPA

Hi all,
I want to create a query inside already taken list of entities form the DB.
So the first query (list of entities) will be taken from DB using JPA entityManager (eg. select from HugeEntity), and the second one from memory (from already taken list).
The reason I want to do this is that DB table is very big (about 200GB of data) and I need to fetch only 50-100 rows and have all other manipulation of fetched data in memory in order to achieve best performance.
Is it possible?

Thank you...
Don't your fortune cookies have a unique id as a number? ...Yes they have but, cookies can be removed and thus, interval is not continuous. E.g. {1,2,5,6,7} after 3 and 4 has been removed.
... you could preload and cache them in a collection and
randomize on the position of an element in that collection...Cacheing seems like a good idea -- I'll probably add some FortuneCookieDAO as layer between my accessor session beans (FortuneCookieAccess) and cookie entity (FortuneCookie). But where should I store instance of this DAO? It has to be accessible from any session bean instance. Into my server's directory (jndi)?
Or did you mean cache on site of web application? That's not possible, my selecting random cookie is responsibility of FortuneCookieAccess ejb.
~~
Adam
PS: I know that using ejbs for fortune cookie selection is not a model usecase (there's saying in my country: "It's like shooting sparrow with a cannon") ... is not a model usecase, but it's just training application.

Similar Messages

  • Find and item Search not working inside custom list in sharepoint 2013

    HI,
    In Sharepoint 2013 , i configured the Search. it is working in home page search Box and Find item search box  inside custom list as well But one particualr custom list  Find an item is not working. Any clue ?Thanks in Advance
    Thanks
    sanjay pradhan  

    Hi,
    According to your description, my understanding is “find an item” search box in a custom list not work in your environment.
    As search box and “find an item” search box in your home page are working, so the search service application is working.
    Do you have any customzation to the particular custom list ?
    If No, I suggest you can full crawl the data in Central Administration ->Manage Service Application->” Search Service Application”-> Manage Content Sources” to test if it works. 
    Also, please check if you have set "Allow items from this list to appear in search results" in list settings->Advanced Setting to true
    Best Regards
    Jerry Guo
    TechNet Community Support

  • ICP entity list

    the members for ICP is dynamically created by HFM when the entities are flagged as ICP.
    is it possible to define a ICP member manually and not having the same in entity list? i
    my compnay has to send data extract to my parent comapny. both the companeis run separte instance of hfm. my compnay does not have parent company defined in the entity dimension. however there will be transcations with the parent and when we send data extract only the parent company name needs to appear in the ICP dimension membe data. is it better to create entity for my parent within our HFM and let HFM automatically create ICP member or create ICP member manually without creating a entity member?

    Hi,
    It wil be interesting to create technical entity (with a specific security class like TECH_ONLYICP) to generate ICP.
    Entity
    |_[None]
    |_LEGAL
    | |_ entity1
    | |_ entity2
    | |_ entity3
    |_TECH_ICP
    |_icp1
    |_icp2
    In this case, you can (in your rules file) put consolidation method to [None] or NOTCONSO to private the IC Elim.
    Chris

  • Constructing a List inside @Entity

    Dear folks,
    I have an entity bean:
    @Entity
    public class EmployeeGroup {
        @ManyToMany
        private List<Employee> employees;
    }when the entity is not yet managed, the employees list is null.
    To get around this, I've put the following into the getter:
    public List<Employee> getEmployees() {
        if (employees == null) {
            employees = new ArrayList<Employee>();
        return employees;
    }I was wondering if that is proper way to do that. Any comments appreciated.
    Regards

    Yes, I had recently determined that the cause was the selectionChange firing on the outer list.
    To answer your question, there really isn't a good reason I can't.  When I started learning the Spark architecture, I challenged myself to forego the halo components altogether, and have been building with that in mind.
    Its really funny, I was looking at that post on your blog yesterday, and I downloaded the source, and couldn't understand how the thing was built.
    So, it looks like I need to do 1 of 2 things.
    1. Figure out a way to change the hit area for the List component, or otherwise swallow the selectedIndexChange on the parent List.
    or
    2. Re-build using the mx:Tree or figure out how yours works.

  • Select random entity using JPA ql

    Hallo,
    I'd like to select random entity from database -- e.g. single fortune cookie that will be displayed on application web page. Unfortunately I've been able to think out only very simple (and inefficient) method so far:// Fortune cookie entity
    @Entity
    class FortuneCookie {
      @Id int id;
      String text;
    * @return random fortune
    public void FortuneCookie getRandomFortune() {
      // Query all fortunes
      Query q = em.createQuery("select f from FortuneCookie f");
      List allFortunes = q.getResultList(); 
      // Select one at random
      return getRandomListElement(allFortunes);
    }How do I perform such (random) select without actually fetching all object from database, please? If possible avoid fallback to native query, I use javaDb for development but product will be deployed on mysql database.
    ~~
    Adam
    PS: I am not sure about forum. Does posts about jpa belong here?

    Thank you...
    Don't your fortune cookies have a unique id as a number? ...Yes they have but, cookies can be removed and thus, interval is not continuous. E.g. {1,2,5,6,7} after 3 and 4 has been removed.
    ... you could preload and cache them in a collection and
    randomize on the position of an element in that collection...Cacheing seems like a good idea -- I'll probably add some FortuneCookieDAO as layer between my accessor session beans (FortuneCookieAccess) and cookie entity (FortuneCookie). But where should I store instance of this DAO? It has to be accessible from any session bean instance. Into my server's directory (jndi)?
    Or did you mean cache on site of web application? That's not possible, my selecting random cookie is responsibility of FortuneCookieAccess ejb.
    ~~
    Adam
    PS: I know that using ejbs for fortune cookie selection is not a model usecase (there's saying in my country: "It's like shooting sparrow with a cannon") ... is not a model usecase, but it's just training application.

  • Are there limitations to running queries inside of transactions?

    I'm seeing altered or no results when running under a transaction:
    context = getXmlManager().createQueryContext();
    XmlQueryExpression.execute(XmlTransaction, XmlQueryContext, XmlDocumentConfig)where:
                TransactionConfig txnConfig = new TransactionConfig();
                txnConfig.setNoWait(false);
                txnConfig.setSync(true);
                transaction = getXmlManager().createTransaction(null, txnConfig);and         XmlDocumentConfig docConfig = new XmlDocumentConfig();
            docConfig.setLockMode(LockMode.RMW);
            docConfig.setLazyDocs(false);The XmlContainer and Environment are transactional. There are node indexes on these containers.
    If I use: XmlQueryExpression.execute(XmlQueryContext, XmlDocumentConfig) all is fine.
    My test conditions are single threaded dbxml 2.2.13 on Windows 2003 Server. Later I'll need to run multi-threaded.
    Any thoughts (aside from upgrade)?
    Known, confirmed problem?
    Are there any limitations to what can be inside of a query that is run inside a transaction?
    Can the query span containers?
    Any impact from setDefaultContainer?
    Does document{ } work any differently?
    Do FLWR queries behave differently?
    Thanks in advance,
    Douglas Moore

    John,
    I'm actually pointing out a functional difference while running with a single threaded non-stressful unit test.
    The inner <report> elements do not show up when transactional api is used.
    Inlining the FLWOR expression does not change the situation.
    I now have the 6 patches applied to dbxml 2.2.13 and see the same results as an unpatched dbxml library.
    My query looks like:
    declare function local:get_ordered($max_reports as xs:decimal)
            for $reports in collection("per-system.dbxml")/reports-catalog/report
                            where $reports/@type = "ABC"
            return $reports
    document{
    <reports-catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.persistable.org/reports-catalog.xsd"
            mime-type="application/pdf" sequence="65241390550" id="ABC">
                    local:get_ordered(1)
    </reports-catalog>
    } Thanks,
    Douglas Moore

  • Display ListObject inside a List in

    Hi,
    is it possible to display the elements of a list object in the frontend?
    I use jsf 2.0.
    Code of Bean:
    package list;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.bean.ManagedBean;
    @ManagedBean(name="list")
    public class ListB implements Serializable{
         //private data
         private List<ListDo> listDo;
         private int size;
         private List<String> testList;
         //Constructor
         public ListB(){
              listDo = new ArrayList<ListDo>();
              ListDo listDo1 = new ListDo(0);
              ListDo listDo2 = new ListDo(1);
              ListDo listDo3 = new ListDo(2);
              ListDo listDo4 = new ListDo(3);
              listDo.add(listDo1);
              listDo.add(listDo2);
              listDo.add(listDo3);
              listDo.add(listDo4);
              testList = new ArrayList<String>();
         testList.add("Mango");
         testList.add("Apple");
         testList.add("Banana");
         //getter setter
         public List<ListDo> getListDo() {
              return listDo;
         public void setListDo(List<ListDo> listDo) {
              this.listDo = listDo;
         public int getSize() {
              return size;
         public void setSize(int size) {
              this.size = size;
         public List<String> getTestList() {
              return testList;
         public void setTestList(List<String> testList) {
              this.testList = testList;
    DataObject
    package list;
    public class ListDo {
         private int index;
         public ListDo(int index){
              this.index = index;
         public int getIndex() {
              return index;
         public void setIndex(int index) {
              this.index = index;
    XHTML:
    <html xmlns="http://www.w3c.org/1999/xhtml"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:p="http://primefaces.prime.com.tr/ui"
         xmlns:c="http://java.sun.com/jsp/jstl/core"
         xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
    <title>index</title>
    </h:head>
    <h:body>
    <h1>List</h1>
    <c:forEach var="listDo" items="#{list.listDo.index}">
    ListDo-Size: <h:outputText value="#{listDo}" />
    </c:forEach>
    <h1>ListTest</h1>
    <c:forEach var="test" items="#{list.testList}">
    ListObjects: <h:outputText value="#{test}" />
    </c:forEach>     
    </h:body>
    </html>
    ListTest is displayed correctly.
    But i need to display the elements inside the ListDo object. (List)
    Thanks

    Hi,
    is it possible to display the elements of a list object in the frontend?
    I use jsf 2.0.
    Code of Bean:
    package list;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.bean.ManagedBean;
    @ManagedBean(name="list")
    public class ListB implements Serializable{
         //private data
         private List<ListDo> listDo;
         private int size;
         private List<String> testList;
         //Constructor
         public ListB(){
              listDo = new ArrayList<ListDo>();
              ListDo listDo1 = new ListDo(0);
              ListDo listDo2 = new ListDo(1);
              ListDo listDo3 = new ListDo(2);
              ListDo listDo4 = new ListDo(3);
              listDo.add(listDo1);
              listDo.add(listDo2);
              listDo.add(listDo3);
              listDo.add(listDo4);
              testList = new ArrayList<String>();
         testList.add("Mango");
         testList.add("Apple");
         testList.add("Banana");
         //getter setter
         public List<ListDo> getListDo() {
              return listDo;
         public void setListDo(List<ListDo> listDo) {
              this.listDo = listDo;
         public int getSize() {
              return size;
         public void setSize(int size) {
              this.size = size;
         public List<String> getTestList() {
              return testList;
         public void setTestList(List<String> testList) {
              this.testList = testList;
    DataObject
    package list;
    public class ListDo {
         private int index;
         public ListDo(int index){
              this.index = index;
         public int getIndex() {
              return index;
         public void setIndex(int index) {
              this.index = index;
    XHTML:
    <html xmlns="http://www.w3c.org/1999/xhtml"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:p="http://primefaces.prime.com.tr/ui"
         xmlns:c="http://java.sun.com/jsp/jstl/core"
         xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
    <title>index</title>
    </h:head>
    <h:body>
    <h1>List</h1>
    <c:forEach var="listDo" items="#{list.listDo.index}">
    ListDo-Size: <h:outputText value="#{listDo}" />
    </c:forEach>
    <h1>ListTest</h1>
    <c:forEach var="test" items="#{list.testList}">
    ListObjects: <h:outputText value="#{test}" />
    </c:forEach>     
    </h:body>
    </html>
    ListTest is displayed correctly.
    But i need to display the elements inside the ListDo object. (List)
    Thanks

  • SQL queries inside html region

    Hi,
    I have html page in my application and i need to display result of the sql query inside this page. I would like to know if i can use the sql queries in html and if yes how can do that.
    My query is select count(*) from Quote Letter master where service = 'Premier Support'
    And i have similar queries like this which i would like to use in the html region.
    Thank you,
    rakesh

    rakesh119 wrote:
    Hi,
    I have html page in my application and i need to display result of the sql query inside this page. I would like to know if i can use the sql queries in html and if yes how can do that.You cannot/should not write sql queries in your html, but in APEX there are different ways to achieve this such as Page Items, PL/SQL Dynamic Content Region etc.
    My query is select count(*) from Quote Letter master where service = 'Premier Support'.For this you better use a page item and compute the items value using a page computation on on-load before header point. Then you can place the page items in a APEX region and also add any styling

  • Receiving error while updating a folder inside sharepoint list

    What my code does - runs through each folders present in a list, and if any of the folders are in the name with current year, then it shall be renamed, ie 2012 to 2012_Backup. Soon after it is renamed we will create a name folder named 2012 and I get error
    here. Below is my code. Please suggest a work arround please.
    for (int i = 0; i < additionalList.Folders.Count; i++)
                        if (additionalList.Folders[i].Folder.Name == Convert.ToString(DateTime.Now.Year))
                            oldFolder = targetList_additionalList.Folders[i];
                            oldFolder[Title] = Convert.ToString(DateTime.Now.Year) + backUp;
                            oldFolder.Update();
                            additionalList.Update();
    SPListItem newfolder = targetList_additionalList.AddItem(workflowProperties.Item.Folder.ServerRelativeUrl, SPFileSystemObjectType.File);
                              newfolder[Title] = Convert.ToString(DateTime.Now.Year);
                       newfolder.Update();
                       targetList_additionalList.Update();
    Error Details :
    Microsoft.SharePoint.SPException: Invalid file name.
    The file name you specified could not be used.  It may be the name of an existing file or directory, or you may not have permission to access the file.
    Shameej

    Hi shameej,
    Based on the error message, the issue should be caused that the new folder is created before the old folder name change.
    From your code sample, you seems to execute the code in workflow, if so, before the new folder item is created, add wait for sometime action, whether this can fix the issue?
    if it isn't the issue, would you please help to provide more information about your code execution environment, in which type of project?
    Thanks,
    Qiao Wei
    TechNet Community Support

  • How to use multi queries inside the RTF file

    Hi all,
    I develope a data source in report developer 10g, and use it to create the RTF files... I have some files wich contains more than 1 query. how can I refer to the fileds in the other queries in side the RTF file, because it's bring the filed from the first query by default??
    ThanX in advance

    ThankX DD
    But that wont work for my case. the problem that I have actually is in RTF.
    for example:
    I have 3 qeuries. A,B & C. A: contains the employee data. B: his Earnings and C: his Deductions.
    in the RTF file it shows me only A contents. wich means it's not entring B & C loops, notice I add <?for-each:B_GROUP_NAME?> and same for C also.
    all my other reports wich have single qeury worked fine.
    Regards to all,
    Message was edited by:
    Adam Ali

  • Finding long running queries inside procedure

    Hi All,
    Without using trace file or not modifying the existing procedure, is there any way to find out the query which is taking longer time (say out of 20) inside oracle procedure?
    Thanks in Advance,
    Geetha

    Hi,
    if you are on your development or test database the best tool (after the sql trace :)) is DBMS_PROFILER. It's easy to use and shows you how long does it take to execute every line of procedure. It helps to find not only slow SQL but also bottlenecks in pl/sql code.
    Another option could be Active Session History that every 1s creates snapshot of active sessions. You have to open new session, run the procedure and use query like this:
    select *
    from v$sql s
        (select sql_id, max(sample_time) - min(sample_time) as duration
        from v$active_session_history
        where sid = sys_context('userenv', 'sid') --SID of the session that executed the procedure
        ) ash
    where s.sql_id = ash.sql_id
    order by duration desc;

  • Hierarchy in Queries (Where-used-list)

    All,
    We have hierarchies in many BW reports. Is it possible to get a where-used-list of hierarchy. Ex. Hierarchy A is used in which reports?
    Any idea?
    Thanks in advance!

    hi Ann,
    take a look some sample code for this kind of where-used list in query (free char, navigational attribute etc)
    Query Issues
    Link technical name and query name
    Where-used list of an attribute (either display or navigational)
    ... will try to code for the hierarchy later...
    hope this helps.

  • Putting Checkboxes inside a list

    ive downloaded this sample from
    http://blogs.adobe.com/aharui/
    and im tryin to use it in my course management application.
    im using amfphp 1.9
    i simply want the app to retrieve the list of courses
    available and populate a list which will the be used in a form so
    that a student can be enrolled onto a course by clicking on a
    checkbox. similar to the sample shown above.
    the courses table contains the following fields
    CourseID
    CourseName
    TeacherID
    below is a break down of my code hope it makes sense
    populating the array collection:
    courseList = new ArrayCollection (
    ArrayUtil.toArray(evt.result) );
    layout:
    <mx:Label x="21" y="290" text="Course"/>
    <mx:List id="list1" dataProvider="{courseList}"
    width="242" x="21" y="307" labelField="CourseName" height="138">
    </mx:List>
    my list currently shows all the courses from the courses
    table, however i want to attach a checkbox to each list.
    the list will be used in a form which allows the user to
    select what courses to enrol the student to. im not sure how to
    exactly
    so how can i get my check boxes to behave in the same way as
    the sample application shown on the links above?

    This works fine for me and I have no scrolling issues. My
    item renderer is copied below. The data property is a custom object
    that supports a _selected attribute.
    So to fill the list I create objects to populate the list and
    create any array collection. This then is the dataprovider for the
    list.
    To determine if an item is checked I iterate the collection
    and examine the selected attribute.
    Item rendererer
    <?xml version="1.0"?>
    <!-- itemRenderers\list\myComponents\RendererState.mxml
    -->
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="120" height="20">
    <mx:Script>
    <![CDATA[
    private function doSelection():void
    if(cb.selected == true)
    data.selected = true;
    else
    data.selected = false;
    ]]>
    </mx:Script>
    <!-- Define the Link control to open a URL. -->
    <mx:CheckBox id="cb" click="doSelection()"
    selected="{data.selected}" width="17"/>
    <mx:Label id="State" text="{data.label}" x="17" y="0"
    width="90"/>
    </mx:Canvas>

  • Quering on the list item collection after being loaded

    I'm a newbie to SharePoint and JavaScript.
    I have a requirement where in I have to get the count of list column and bind to an HTML element.
    Example:
    Red,Blue,Green are the columns and i have to get the count of "Red" columns ,"Blue" column and "Green" columns that are filled after loading the items.
    //To get the context
    var context = new SP.ClientContext.get_current();
    //To get the list
    var pwh_list = pmh_context.get_web().get_lists().getByTitle('test');
    //Query for the list
    var pwh_query = new SP.CamlQuery();
    //Specifying the xml for the query.
    pwh_query.set_viewXml("<GroupBy Collapse='True'><FieldRef Name='Vertical' /></GroupBy><OrderBy> <FieldRef Name='Vertical' Ascending='True' /></OrderBy>");
    //Get the items based on the query
    var pwh_items = pwh_list.getItems(pwh_query);
    //Loading the items
    context.load(awh_items);
    context.executeQueryAsync(pmh_SuccessItems, pmh_Failitems);
    function pmh_SuccessItems()
    //Get the count of "Red","Blue","Green" columns
    function pmh_Failitems()
    These counts have to be bound to the HTML table.
    Kindly help.

    I din't get the last point. Were you been able to do it?
    Just use three different variable for return items pwh_red_items,pwh_blue_items
    context.load(pwh_red_items);context.load(pwh_blue_items);
    Then on success use pwh_red_items.Count
    , pwh_blue_items.Count something like this
    Please mark a post helpful/answer if it is really helpful or answer your query

  • Unable to jump inside contact list - iphone 3G firmware 3.0

    Hey everyone. I've recently upgraded my firmware to version 3.0. After doing that, I'm unable to jump directly to the contacts starting with a specific letter. The whole A-Z letters on the right side shows in a gray sheded box whenever trying to tap. Is it only me having the problem or everyone? Also, I get no result at all when using the Contact search list. My Groups is set to showing All contacts

    I just upgraded to 3.0. It froze during the update, after waiting for hours. I forced shut down the computer, and started over. It was able to update the software, and restore my data, but I am experiencing the same problems in contacts. Tried reinstalling the software, and a soft restart, no change. How do you change back to the older software?
    thanks, Ron

Maybe you are looking for

  • Pricing problem-Urgent

    Hi all, iam getting a problem regarding pricing. When i make a Sales doc. with reference to an invoice, everything is being copied from invoice to the sales doc.-customer, material  and its no. , sales area, payment terms, incoterms, and material qty

  • Thunderbird Preferences no longer lets you open in a browser. Can't see illustrations.

    Used to be just a one-liner: Open message in browser, or something like that. Now there are a bunch of lines, none of which permits you to open in a browser. Case in point: message from Marlin P. Jones & Assoc. Inc. <email specials @mpja.com> Used to

  • How to load content of my text file into a Vector?

    Hi! Two questions. Let say I have used BufferedReader(new FileReader(c:/java/MyText.txt)) to read from MyText.txt file. I want to know how to load content of this file (every line describe each photo in my photo-set) into a Vector? And how to associa

  • FaceTime will not run after update to 10.6.7

    Updated the OS to 10.6.7 earlier today. Tried to run FaceTime this evening, and found that it will not start. First indication of a problem was that the FaceTime icon was missing, instead a generic icon was present. Tried to start FT, and found that

  • Finding the A frame with G Cadence plug in or any other mean

    hi, I'm working with an editor to successfully reverse telecine some clips. we did telecine for a 24fps film to 30 non-drop NTSC in Singapore. They don't indicate the alphabets for the frames and instead they use numbers. we am trying to figure out t