Optimization « Query « JPA Q&A





1. Getting Hibernate to do simple updates, instead of enormous select then updates    stackoverflow.com

Lets setup the question first. What I have is >4 tables: Customer, Address, Order, OrderItems. Each are mapped using Hibernate Annotations and accessed through a Spring DAO/Services layer. What I am trying ...

2. How to query three related tables efficiently (JPA-QL)    stackoverflow.com

Let's say I have entities A, B, C and each A has many B and C entities. I want to query a load of A entities based on some criterea, and ...

3. HIbernate Query taking very long time    stackoverflow.com

I am trying optimize my code. I fetching the data using hibernate, when i am running the query directly on the database it fetching the results in 2secs, rowcount around 2800. ...

4. Hierarchical Hibernate, how many queries are executed?    stackoverflow.com

So I've been dealing with a home brew DB framework that has some seriously flaws, the justification for use being that not using an ORM will save on the number of ...

5. JPA Query optimization by avoiding JOIN to lookup table?    stackoverflow.com

Imagine a table emp:

CREATE TABLE emp
( id           NUMBER
, name         VARCHAR
, dept_code   ...

6. Why does hibernate do the SELECT before SAVE?    stackoverflow.com

Why does hibernate do a select before saving an object? I can't find useful information on internet. Is this normal behavior before every save? I found this topic, select Query Run ...

7. Hql query optimization - return indexed id or the whole object    stackoverflow.com

I have a databas table with cca. 327 000 entries. (SQL Server 2005, Hibernate 3) I have to generate a report that queries this table for 300 times. The Hql query ...

8. oracle order by runs terribly slow    stackoverflow.com

i'm doing a query like this one and it takes 6 seconds to complete :

select * 
from ( select aaa."ID" 
      from "aaa"  
  ...

9. Optimal SQL query    stackoverflow.com

I have a list of ids and need to retrieve each record by id. Our application uses hibernate as ORM framework. Can you anyone say in terms of performance which one ...





10. Hibernate: query optimization    coderanch.com

You could try to put an index onto some of the columns from your where clause. You also could try to replace one or more JOINs with subselects. I dont know which DB you are using (8 mins sounds insane). You can inspect the explain plan of the sql query to see whats going wrong there, if your DB got something ...

11. JPA query optimization    coderanch.com

hi all, i have a table "Semiproduct" and have the id of the "Semiproduct", in tables "SemiproductSales" and "SupplyArea" as foreign key, say for example @Entity public class Semiproduct{ @Id @GeneratedValue(strategy = GenerationType.AUTO) @Basic(optional = false) @Column(name = "ID", nullable = false) private Long id; @Basic(optional = false) @Column(name = "text") private String text; @OneToMany(cascade = CascadeType.ALL, mappedBy = "semiproduct") private ...

12. Need Optimization Advice For One-To-One Relationship Query    forum.hibernate.org

I am executing a query involving a large IN clause between two entities in a one-to-one relationship. When I execute the query in SQL the way I would do it, it runs in less than half a second. When I do it through JPA-QL with Hibernate, the length of time increases by a factor of 10. I would love some guidance ...

13. Need help or best practice for optimizing a query    forum.hibernate.org

Newbie Joined: Thu May 06, 2010 12:04 pm Posts: 1 Hi, I have the following function: Code: @SuppressWarnings("unchecked") public List getMenuItems(Long groupID, Long userID, String filter) { System.out.println("-!-!-!- begin getMenuItems DAO -!-!-!-"); List result = new ArrayList(); ...

14. SELECT Optimization Suggestion    forum.hibernate.org

During a previous project using Perl and MySQL, I was able to significantly increase performance by fetching n rows with n/x queries of the type: SELECT * FROM table WHERE id IN (id1,id2,id3,...,idx) instead of n queries of the type SELECT * FROM table WHERE id=id1 Every time Hibernate materializes a collection and I see the long series of identical queries ...

15. many-to-one query optimization... any further documentation?    forum.hibernate.org

I've read numerous posts and the documentation related to improving performance (chapter 11) but I am still concerned over the number of queries required to load an object with several many-to-one relationships (the one-to-many relationships are set to lazy load and thus not contributing to the problem). I am using the object references returned by my persistence classes to populate web ...

16. Query Optimization    forum.hibernate.org

I have a "deliveries" table which contains all my deliveries. From these, I need to report on various statistics - for example: how many were late, how many were damaged, how many customers were satisfied. I am trying to determine whether I should do a different query for each statistic ( select * from delivery where damaged = true ) OR ...





17. Help with query optimization    forum.hibernate.org

Senior Joined: Sun Oct 26, 2003 5:05 am Posts: 139 While I've got a pretty good handle on loading collections, I'm not very good at loading many-to-one relations. I was wondering what would be the best and quickest way to make business lazy on my RnsTransaction mapping. The reason I don't want to load it is because the query is carrying ...

18. Comprehensional Problems - optimizing query/design    forum.hibernate.org

Hello I am having a mapping structure as shown in detail below. There are n services which have n MMSAbos. Each MMSAbo represents the startdate of one content item and the content referer and other data. What I did sofar was to enable caching, lazy loading and batch statements. With cacheing it seems that after reloading the page (which displays the ...

19. Query optimization suggestion    forum.hibernate.org

Hi, I ran some Hibernate code through a profiler and noticed that AbstractSessionImpl.getHQLQueryPlan() is invoked both from Session.createQuery() and Query.list(). In both cases, autoFlushIfNecessary() is invoked and this operation is rather expensive. Why do you need to flush the session *both* at Query creation and at query invocation? Isn't it enough to only flush at invocation time?

20. MySQL case insensitive like optimization    forum.hibernate.org

Hi, I have a suggestion for the MySQL dialect. When you perform a query by example, case insensitively and matchmode = start it results in the SQL code for MySQL: "lower(DB_Field) like ?" This syntax means MySQL doesn't use any index there might be on DB_Field. As it turns out, in MySQL executing "DB_Field like ?" is also case insensitive, so ...

21. HQL->SQL Optimization Bug with exists() clause    forum.hibernate.org

22. Syntax help on LEFT JOIN queries in HQL, query optimization    forum.hibernate.org

I have been writing HQL queries in hibernate to get all the tables' columns' data in one single query just like any other JDBC query. Writing LEFT JOINS on many tables was harder and I was not sure if I was doing it right anyways. Could any body suggest a better way to modify the object and mapping file to LEFT ...

23. Hibernate query optimization    forum.hibernate.org

Hi, I have the following query. This is the generated SQls by our application. Prepared|Query|SELECT COLLECTION0_.ID AS [color=red]ID232_0_, [/color]COLLECTION0_.TOTALDUE AS TOTALDUE232_0_, COLLECTION0_.MINIMUMDUE AS MINIMUMDUE232_0_, COLLECTION0_.PASTDUE AS PASTDUE232_0_, COLLECTION0_.OVERLIMIT AS OVERLIMIT232_0_, COLLECTION0_.LASTPAYMENTAMT AS LASTPAYM6_232_0_, COLLECTION0_.LASTPAYMENTDATE AS LASTPAYM7_232_0_, COLLECTION0_.CREDITLIMIT AS CREDITLI8_232_0_, COLLECTION0_.CURRENTBALANCE AS CURRENTB9_232_0_, COLLECTION0_.PAYMENTDUEDATE AS PAYMENT10_232_0_, COLLECTION0_.CYCLEDATE AS CYCLEDATE232_0_, COLLECTION0_.CYCLESPASTDUE AS CYCLESP12_232_0_, COLLECTION0_.DELINQUENCYHISTORY AS DELINQU13_232_0_, COLLECTION0_.SEGMENTCD AS SEGMENTCD232_0_, COLLECTION0_.ACCOUNTID AS ACCOUNTID232_0_ FROM ...

24. query optimization - unnecessary join    forum.hibernate.org

Hi, I'm currently trying to write a query with a simple subselect on a many-to-many join table in HQL. I have two entity classes: User and Widget. - Widget has a many-to-one association to User called 'owner'. - User has a many-to-many association to itself called 'friends'. Now I want to select all Widget entities for all friends of a single ...