-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Poor performances with groupby
PostPosted: Mon Mar 29, 2010 1:21 pm 
Newbie

Joined: Sun Feb 14, 2010 7:13 pm
Posts: 6
Hi, I have the following entities (I omitted the getters and setters)
Code:
@Entity
@NamedQueries( {
      @NamedQuery(name = "getClassificationStatistics",
                query = "select c.classification as label, count(*) as numberOfPaper " +
                      "from Classification c " +
                      "where c.article.year between :firstYear and :lastYear " +
                      "group by c.classification " +
                      "order by c.classification"),
      @NamedQuery(name = "getClassificationFromArticle",
                query = "from Classification c where c.article = :article") })
public class Classification {
   @Id
   @GeneratedValue
   private long identifier;
   
   @OneToOne
   Article article;
   
   String classification;

and
Code:
@Entity
@Table(name = "ARTICLES")
public class Article {
   @Id
   @GeneratedValue
   @Column(name = "ArticleId")
   private long identifier;

   private String title;

   @Type(type = "text")
   private String articleAbstract;

   private int year;

   @Lob
   private byte[] fullTextPdf;

   @ManyToOne
   private Journal journal;

   @ManyToMany
   @JoinTable(name = "Article_Author", joinColumns = { @JoinColumn(name = "ArticleId") }, inverseJoinColumns = { @JoinColumn(name = "AuthorId") })
   private List<Author> authors = new Vector<Author>();

My issue is with the getClassificationStatistics that takes long time to be executed. Is there any way to add indexes to make it faster?

Moreover I am not sure if the relation between the entities I defined is the right one. So far I just annotated with a @OneToOne, without telling that in Classification the Article object has to be a foreign key. Is that right or should I modify something?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.