Efficient Queries involving multiple relationship in JPA

Hello,
I'm using JPA with provider Hibernate.
In order to get data from multiple tables (say 5 tables) I would use SQL JOIN and 'SELECT' only required columns. This would be the most efficient way and would scale well.
In JPA how do I achieve this ?
(It is not just 1-2 tables, but data has to be pulled from 10 related tables each having 15+ columns)
Thank You.

one object with 150 persistent attributes? sounds like a bad data model, a bad object model, or both. time to refactor.
%

Similar Messages

  • How to pick consignment stock @ FIFO method when involved multiple vendors

    Dear Guru s ,
    I need some information/ logic  on how to pick consignment stock @ FIFO method when involved multiple vendors (who supplies consignement goods) .
    1)We have tried to determine the vendor @ FIFO method from the material document date & time   with 101 K  mvmt type
    2) when we check MSEG table we are unable to get the current stock updates .For example Vendor A stock is showing 60 KG in MMBE , but MSEG is showing only 45 KG for the same vendor & storage location  .
    Can anyone provide me the logic / info on the same.
    Thanks
    Anil

    Hi Anil
    MMBE will show you total stock, your logic is correct , you can go for MSEG , but you need to add opening stock for that material for the period.
    Suppose you are looking for report between 2nd august to 10 august , then you need to take opening stock on 2nd august and then add all goods receipt( 101 k) between 2nd to 10th and you will get correct stock on 10th ( same as MMBE)
    Note : I am assuming that current date is 10th august. If you want to see stocks on particular date then go for MB5B.
    Now as per your requirement , you can identify goods movement based on FIFO , follow same logic , pick time and date from MSEG for 101 k movement type.
    Regards
    Ravi.

  • Assign multiple relationships at once

    Hi everyone...I am working in Primavera P6 Project Management Release: 7.0 Service Pack 3 (Build #: 00033036)
    When trying to assign multiple relationships at once, my computer will not allow me to capture multiple activities that have been assigned as either a predecessor or successor. I can highlight them, but when I click the assign button they all briefly flash as being captured then the assignment only shows the first activity in my complete schedule?
    I am able to log into a co-workers machine with my credentials and perform this task, but not on my machine. Do you have any suggestions?
    Thanks

    Hello,
    I assume this is all in the same project? It sounds like your project profile security settings could be different than your co-workers. I would see if there is a conflict between your settings from the admin perspective.
    Check these two lines in project security profile.
    Edit Project Activity
    Relationships
    Create, edit, and delete a project’s activity
    relationships.
    Add/Edit Project
    Activities Except
    Relationships
    Create and edit a project’s activity information, except
    activity relationships. To edit activity IDs, a user must
    also be granted the Edit Activity ID project privilege.

  • Spatial overlay queries involving tables with different spatial extents

    We are using GeoMedia Professional 6.1 with an Oracle 10g database. For validating geometry, we use a standard minimum bounding rectangle (MBR) that is fairly tight to our city boundary. Some city departments are requesting that we extend the spatial limits to create a larger MBR for some new features. This will involve using a new SDO_DIMINFO array in the MDSYS.SDO_GEOM_METADATA_TABLE and creating new spatial indexes. It is our intention to leave the existing features "as-is" with the original MBR and spatial indexes. I have done some preliminary testing in GeoMedia and have not run into any issues when doing spatial queries involving features with different MBRs. Spatial intersections, spatial differences and spatial filters seem to complete in a reasonable amount of time, even with large data sets. Does anyone have any experience using different MBRs with Oracle spatial overlay queries? Are there any other potential issues we should be aware of when working with tables that are created with different spatial extents such as performance?

    Luc ... Thank you for supplying the URL for Simon Greener’s website. This article supports information we already received from our GIS software provider.
    With regards to your questions: One of the checks carried out in our “ValidateGeometry” procedure is to ensure that a new or modified geometry is within the bounding rectangle defined by the SDO_DIMINFO. An error is raised if the user tries to add a polygon that is well beyond the city boundary rather than within the prescribed city area. Currently, we do not use different MBR’s as layer extents (there are only a couple of exceptions). We are in the process of conducting system and performance testing to identify potential issues that may be encountered when tables created with expanded upper and lower bounds are used in downstream applications such as intranet/internet web maps. We are still trying to identify any potential “hotspots”.

  • Multiple relationship modeling

    Hello,
    I am hitting a bug/issues/misunderstanding on my side with data modeller 4.0.0.833 (I had this issue in the previous versions too).
    I was trying to model multiple relationships from a entity to a detail entity and am hitting some problems. I have the following situation (simplified) :
    Party Entity : Party ID (PID), Party Name
    Transaction Entity : Trans ID (PID), cost (number)
    I then create 2 1-to-many relationship from party to transaction:
    Party -> Transaction (1 to many)
    Party -> Transaction (1 to many)
    This creates 2 FKs on the transaction entity called (Party ID and Party ID1). I rename this attributes in the transaction entity as "From Party" and "To Party"
    I then do a engineer to relational model.
    This then ignores the attribute names in the transaction entity I had given ("From party" and "to party") and creates 2 new columns - "Party_Party_ID" and "Party_Party_ID1".
    Is there a way I can preserve the names I had given in the logical model for the FKs when engineered to Physical? Or is this a bug?
    Secondly, Is it possible in the Relation properties dialog box (by double clicking the relationship lines in the logical model) in the target cardinality section to select the FKs I had created ("From Party" and "to Party") so that I could document correctly which is the "from" and which is the "to".
    Thanks in advance.
    AK

    Hi AK,
    you have 2 options:
    1) clear "Apply name translation" check box in engineering dialog
    2) use proper setting for naming template and names in your model (as Dimitar suggested) - naming templates are available in design properties dialog>"Settings>Naming standards">templates"
    2.1 change naming template for "Column Foreign key" to {relationship}
    2.2 Rename your relationships as "From Party" and "To Party"
    3.1 Check "Apply name translation" check box in engineering dialog
    Philip

  • Workbook with multiple queries on multiple tabs

    Scenario: There is a workbook with multiple queries on multiple tabs.
    In 3.x, it was possible to refresh only a select query within the WB but I'm not finding this to be the case in the NW04s BEx Analyzer. It seems that it will always refresh all queries on all tabs.
    Do any of you know a way around this?

    Hi Bigtoja (and others).
    This is not possible in BI/2004s.
    Please refer to https://websmp106.sap-ag.de/~sapidb/011000358700004483762006E page 23. It seems that it will be implemented in a stack sometime in 2008.
    BR
    Stefan

  • OBIEE BI Apps data level security involving multiple PeopleSoft Segments

    Has anyone implemented OBIEE BI Apps data level security involving multiple PeopleSoft Segments and can provide some tips?
    Our PeopleSoft security grants access by 2 segment combinations:
    All Segment 3 (Department)  and any Segment 6 (Project)
    Specific Segment 6
    Specific combinations of Segment 3 and Segment 6
    In addition, there is a flag to indicate if the user also has access to payroll data. Payroll access is a subset of the general finance access.
    We've got a security init blocks running successfully for general finance and payroll access. We've created Data filters on the Segments for general finance access and GL Account for payroll access.  We designed dashboards to use Dept and Project from the Segments on the general finance dashboards and pull Dept and Project from GL Account for the payroll dashboards.
    The problem is both data filters are being applied to the general finance dashboards since the joins behind the scenes on the general finance dashboards use GL Account.
    Does anyone have a suggestion?

    Business Intelligence Applications

  • Size of a specific table on disk? Queries over multiple (2) tablespaces?

    I am looking for a way to find out (for Oracle 9.2.0.1.0).
    How much space does each or a specific table require on disk?
    (whether with indices or without is the other question).
    And how much "payload" data is in each or a specific table?
    Another question - of my team leader - is:
    Is it possible to make queries over multiple (2) tablespaces?
    I assume - no - am I right?
    Thank you for precise answers as well as links to other threads in this forum (where I did not find it until now),
    and chapters in online documentation - or other sources.
    PS: I know SQL, PL/SQL a bit.
    We have Oracle Enterprise Manager console and SQL*Plus console.

    >
    The table size can not be found in bytes precisely, but in number of blocks of a certain size allocated for this table (index etc.).
    select segment_type,segment_name, Sum(Bytes)/1024 as kB from DBA_EXTENTS
    where tablespace_name = 'xyz' group by segment_type,segment_name;
    There are more blocks allocated for a table than space is needed by the current data amount.
    I guess, that this table was once bigger and has been emptied a bit.
    >
    A table grows in extents that get filled then with new rows. The columns
    blocks and bytes of user_tables get populated from dba_stats.
    In below example, the table rows have filled up to MB_TABLE the extents:
    SQL> select table_name,blocks*8/1024 as mb from user_tables order by 1;
    TABLE_NAME                   MB_TABLE
    CUSTOMERS            11.6015625
    SALES                 278.96875
    SQL> select segment_name,bytes/1024/1024 as mb from user_segments order by 1;
    SEGMENT_NAME                 MB_SEGMENT
    CUSTOMERS                    12
    SALES                       285If you later on delete again from the tables, that does not deallocate extents nor remove the high water mark unless you reorganize the table:
    SQL> select count(*) from customers;
      COUNT(*)
         55500
    SQL> delete from customers where rownum<25000;
    24999 rows deleted.
    SQL> commit;
    Commit complete.
    SQL> select segment_name,bytes/1024/1024 as mb from user_segments order by 1;
    SEGMENT_NAME                 MB
    CUSTOMERS                    12
    SALES                       285
    SQL> select table_name,blocks*8/1024 as mb from user_tables order by 1;
    TABLE_NAME                   MB
    CUSTOMERS            11.6015625
    SALES                 278.96875
    SQL> exec dbms_stats.gather_table_stats('ADAM','CUSTOMERS')
    PL/SQL procedure successfully completed.
    SQL> select table_name,blocks*8/1024 as mb from user_tables order by 1;
    TABLE_NAME                   MB
    CUSTOMERS            11.6015625
    SALES                 278.96875
    SQL> alter table customers enable row movement;
    Table altered.
    SQL> alter table customers shrink space;
    Table altered.
    SQL> exec dbms_stats.gather_table_stats('ADAM','CUSTOMERS')
    PL/SQL procedure successfully completed.
    SQL> select segment_name,bytes/1024/1024 as mb from user_segments order by 1;
    SEGMENT_NAME                 MB
    CUSTOMERS                6.4375
    SALES                       285
    SQL> select table_name,blocks*8/1024 as mb from user_tables order by 1;
    TABLE_NAME                   MB
    CUSTOMERS             6.2265625
    SALES                 278.96875Kind regards
    Uwe
    http://uhesse.wordpress.com

  • Why Queries involving Parameter Markers will not be cached?

    Why Queries involving Parameter Markers will not be cached?
    While implementing row level security we have hit a raodblock .Authentication occurs by taking the present User through VALUEOF(NQ_SESSION."USER").
    The reports involving this authentication are not getting cached.
    Searching I got information from this link http://obieeblog.wordpress.com/2009/01/19/obiee-cache-is-enabled-but- saying Queries involving Parameter Marker will not be cached.
    Any alternative available for this???

    The same is available in the Infrastructure Installationand Configuration Guide also.

  • Control multiple updates and queries within one transaction in JPA

    Hi,
    I have a question regarding control multiple updates and queries within one transaction. We are using EclipseLink 2.3.1. With below code, will I be able to:
    - have all insert, update, select queries committed in one transaction;
    - queryGetBalance will return the latest OrgBalance after update;
    - if one fails, everything rolls back.
    Thanks!
    Jeffrey
    PS: I realized that I cannot use em.getTransaction().begin() and em.getTransaction().commit(), since I am using JTA.
    =============
    @PersistenceContext(unitName="Test")
    EntityManager em;
    em.setFlushMode(FlushModeType.COMMIT);
    newTransaction.setAmount(1000);
    newTransaction.setType("check");
    em.persist(newTransaction);
    orgAudit.setUpdateUser("Joe")
    orgAudit.setupUpdateTime(time);
    em.merge(orgAudit);
    Query queryUpdateBalance = em.createQuery("update OrgBalance o set o.balance = o.balance + :amount where orgId = :myOrgId");
    queryUpdateBalance.setParameter("amount", 1000);
    queryUpdateBalance.setParameter("myOrgId", 1234);
    Query queryGetBalance = em.createQuery("select OrgBalance o where o.orgId = :myOrgId");
    queryGetBalance.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
    queryGetBalance.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
    queryGetBalance.getResultList();
    em.flush();
    Edited by: JeffreyW on Dec 12, 2011 10:34 AM

    Yes, the operation will be in a single transaction, assuming you are using a JTA managed SessionBean and the code is part of a SessionBean method.

  • JPA multiple relationships/associations between same entities

    I want to have a Person entity that has two bi-directional relationships to the Name entity: name and aliases.
    I have implemented it like so:
    @Entity(access = AccessType.FIELD)
    public class Person
         @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="person_name")
         Name name;
         @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="person_aliases")
         private List<Name> aliases = new ArrayList<Name>();
    @Entity(access = AccessType.FIELD)
    public class Name
         @OneToOne
         private Person person_name;
         @ManyToOne
         private Person person_aliases;
         public Person getPerson() {
              return getPerson_name() != null ? getPerson_name() :
                   getPerson_aliases();
    }This seems to work, but I�m wondering if there�s a better way to do it. I don�t like the multiple Person properties in the Name entity.
    Thanks

    Your table design is completly wrong. I am now sure how you are maintaining OrderDate table. SQL Server is RDBMS. Without relation how will you pick those rows from Order table whose order date is equal exactly equal to datefield in OrderDate table. The
    only way is to derived endofDay and endofMonth in the select query directly. I understand endofMonth. But what is EndofDay ? And that too a date datatype ??
    You can run the below query but it will not return specific order date from order table,
    SELECT * FROM [ORDER] WHERE
    CONVERT(CHAR(10),ORDERDATE,101) IN (SELECT CONVERT(CHAR(10),endOfDay,101) FROM ORDERDATE)
    SELECT * FROM [ORDER] WHERE
    CONVERT(CHAR(10),ORDERDATE,101) IN (SELECT CONVERT(CHAR(10),endOfMonth,101) FROM ORDERDATE)
    Even if i JOIN the two table by orderdate and endofDay/endofMonth, we will not received specific orderDate. And this is becouse if your Order table contains multiple orderDate that are matching to either endofDay or endofMonth, the final output will contain
    multiple orderDate details. I don't think this is what you need. Therefore you need to modify the OrderDate table or provide us the definition for endofDay and endofMonth, and how are you maintaining.
    Regards, RSingh

  • Order of Variables in selection criteria involving multiple queries

    Hello,
    I've a query Q1 which has one of it's variables defined with replacement qry Q2. The query Q2 has a variable defined with replacement qry Q3. When i put qry Q1 in a application designer template and run the report, The selection criteria has the variables in the order of Q3, Q1 instead of Q1, Q3.
    How can i control this order of variables appearing in sel criteria.
    (i've observed that if there are 2 queries in the report the order is correct i.e Q1, Q2).
    The second problem is, in the report i've added a
    'Text Element' object. In the webitem tab, for property
    'List of Text Elements', i've added all the variables
    of the Query, The variable of qry Q1 are populated in the report output, but the variable of qry Q3 are not, How do i display this variable.
    For the  variables where no criteria is given, the report shows the text as 'Empty Demarcation'. How can this be made blank.
    Regards,
    Nagendra.

    Hi Nagendra,
    For removing the Empty Demarcation, in SE38 > SAPLRRSV > look at Text Element 301 and blank it out.
    Hope this helps...

  • Warehouse partitioning - performance of queries across multiple partitions?

    Hi,
    We are using Oracle 11.2.0.3 and have a large central fact table with several surrogate ids which have bitmap indexes on them and have fks looking at dimension tables + several measures
    (PRODUCT_ID,
    CUSTOMER_ID,
    DAY_ID,
    TRANS_TYPE_ID,
    REGION_ID,
    QTY
    VALUE)
    We have 2 distinct sets of queries users look to run for most part, ones accessing all transactions for products regradless of the time those transactions happened (i.e. non-financial queries - about 70%,
    queries determining what happened in a particular week - 20% of queries.
    Table will have approx 4bn rows in eventually.
    Considering adding extra column to this DATE and range partition this to allow us to drop old partitions every year - however this data wouldn't be joined to any other table.
    Then considering sub-partitioning by hash of product_id which is surrogate key for product dimension.
    Thoughts on performance?
    Queries by their nature would hit several sub-partitions.
    Thoughts on query performance of queries which access several sub-partitions/partitions versus queries running aganist a single table.
    Any other thoughts on partitioning strategy in our situation much apprecaited.
    Thanks

    >
    Thoughts on query performance of queries which access several sub-partitions/partitions versus queries running aganist a single table.
    >
    Queries that access multiple partitions can improve performance for two use cases: 1) only a subset of the entire table is needed and 2) if the access is done in parallel.
    Even if 9 of 10 partitions are needed that can still be better than scanning a single table containing all of the data. And when there is a logical partitioning key (transaction date) that matches typical query predicate conditions then you can get guaranteed benefits by limiting a query to only 1 (or a small number) partition when an index on a single table might not get used at all.
    Conversely, if all table data is needed (perhaps there is no good partition key) and parallel option is not available then I wouldn't expect any performance benefit for either single table or partitioning.
    You don't mention if you have licensed the parallel option.
    >
    Any other thoughts on partitioning strategy in our situation much apprecaited.
    >
    You provide some confusing information. On the one hand you say that 70% of your queries are
    >
    ones accessing all transactions for products regradless of the time those transactions happened
    >
    But then you add that you are
    >
    Considering adding extra column to this DATE and range partition this to allow us to drop old partitions every year
    >
    How can you drop old partitions every year if 70% of the queries need product data 'regardless of the time those transactions happened'?
    What is the actual 'datetime' requirement'? And what is your definition of 'a particular week'? Does a week cross Month and Year boundaries? Does the requirement include MONTHLY, QUARTERLY or ANNUAL reporting?
    Those 'boundary' requirements (and the online/offline need) are critical inputs to the best partitioning strategy. A MONTHLY partitioning strategy means that for some weeks two partitions are needed. A weekly partitioning strategy means that for some months two partitions are needed. Which queries are run more frequently weekly or monthly?
    Why did you mention sub-partitioning? What benefit do you expect or what problem are you trying to address? And why hash? Hash partitioning guarantees that ALL partitions will be needed for predicate-based queries since Oracle can't prune partitions when it evaluates execution plans.
    The biggest performance benefit of partitioning is when the partition keys used have a high correspondence with the filter predicates used in the queries that you run.
    Contrarily the biggest management benefit of partitioning is when you can use interval partitioning to automate the creation of new partitions (and subpartitions if used) based solely on the data.
    The other big consideration for partitioning, for both performance and management, is the use of global versus local indexes. WIth global indexes (e.g. a global primary key) you can't just drop a partition in isolation; the global primary key needs to be maintained by deleting the corresponding index entries.
    On the other hand if your partition key includes the primary key column(s) then you can use a local index for the primary key. Then partition maintenance (drop, exchange) is very efficient.

  • How to use a Web Template with queries from multiple BW Systems?

    Hi all,
    can anybody help me how to use a Web Template with queries (DATA PROVIDER)in it from multiple BW Systems?
    Thanks in advance, best regards
    Frank

    Great! Thanks for the quick response.
    Have you tried this for XMLA datasources created within the EP system also?
    i.e use Web Analyzer to create a view from the XMLA source and use that view within WAD?
    Thanks.

  • Issue with DB Adapter involving multiple tables

    Hi,
    Am facing an issue with DB Adapter with multiple tables. Here are the details.
    I have 4 tables. Header, Details,Products and Devices. The relationship is defined as follows:
    Header has 1:M relationship with Details.
    Details has 1:M relationship with Products.
    Products has 1:M relationship with Devices.
    I want to select the details from all the tables for a particular header_id and detail_id. Defined 2 parameters and query is created with parameters.
    SELECT DISTINCT t0.FILE_NAME, t0.UNIQUE_SEQUENCE_NUMBER, t0.HEADER_COUNT, t0.TOTAL_DEVICE_COUNT, t0.FILE_DATE, t0.FILE_SEQ_NUMBER, t0.DEVICE_COUNT, t0.PHONE_TYPE, t0.PHONE_OWNERSHIP, t0.TRANSACTION_TYPE, t0.PURCHASE_ORDER_NUMBER, t0.CUSTOMER_ID, t0.CUSTOMER_DEST_SUFFIX, t0.LOCATION_DESTINATION, t0.MASTER_FACTORY_ORDER, t0.MASTER_FACTORY_ORDER_LINE_NUM, t0.ENT_ORDER_NUMBER, t0.DELIVERY_IDENTIFICATION_NUM, t0.UEDF_REVISION_NUM, t0.STATUS, t0.INBOUND_BPEL_INSTANCE_ID, t0.ERROR_DESCRIPTION, t0.INBOUND_FILE_VERSION, t0.CREATED_BY, t0.CREATION_DATE, t0.UPDATED_BY, t0.UPDATE_DATE FROM EDF_HEADER_STG_INT t0, EDF_DETAILS_STG_INT t1 WHERE (((t0.FILE_NAME = #file_name) AND (t1.EDF_SERIAL_TYPE = #prod_type)) AND (t1.UNIQUE_SEQUENCE_NUMBER = t0.UNIQUE_SEQUENCE_NUMBER))
    I expect the DB Adapter to retrieve the records for the parameters passed. i.e only those records from details table which matches with the parameter I passes in (t1.EDF_SERIAL_TYPE = #prod_type) . But I see that the DB Adapter retrieves all records from the details table for a particular unique_sequence_number(unique_sequence_number is primary key for headers table and foreign key for details table). Could you pls tell me how can I retrieve only selected records from the details table?
    Regards,
    Meenu

    Yes. When I run this query in DB, I get one record . While defining DB Adapter, I have imported 4 tables and also defined the relationship between the tables. In my case, column unique sequence number is primary key of headers table and foreign key of details table.The above select query is generated by the DB Adapter for the parameters I have passed in.
    My data is as follows:
    Headers table:
    file_name uniq_seq_num
    file_1.xml 220
    Details table
    product_id unique seq num edf_prod_type
    111 220 A
    112 220 B
    113 220
    Now, I call DB Adapter with parameters 'file_1.xml' (file_name)and 'A'(prod_type). I expect the DB adapter to retrieve only one record with product_id 111 in the detailscollection. But I see that the adapter retrieves all records from the details table without considering the value of prod_type.
    Edited by: user13276819 on Mar 19, 2012 6:32 AM

Maybe you are looking for