-->
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: How to use Projections in JPA
PostPosted: Thu Aug 04, 2011 9:46 am 
Beginner
Beginner

Joined: Sat Nov 07, 2009 10:31 am
Posts: 22
Hi,
Hibernate gives the feature of selecting (filtering) the no of feilds/or columns needed with Projections Concept.

My Doubt here is how can utilize the same kind of stuff to improve the Performance in JPA.
please suggest me if there is any approach.

Code:
import java.util.Date;


public class Employee {
   private int empId;
   private String empName;
   private Date dob;
   private long salary;
   public int getEmpId() {
      return empId;
   }
   public void setEmpId(int empId) {
      this.empId = empId;
   }
   public String getEmpName() {
      return empName;
   }
   public void setEmpName(String empName) {
      this.empName = empName;
   }
   public Date getDob() {
      return dob;
   }
   public void setDob(Date dob) {
      this.dob = dob;
   }
   public long getSalary() {
      return salary;
   }
   public void setSalary(long salary) {
      this.salary = salary;
   }
   
   
}



let us consider the above is my entity with jpa annotations.

if i run the Named Query like 'From Employee' this will fetch 4 columns like 'select * from employee'

But i need 'select empId,empName from Employee' - this will return the List<Object[]> but not List<Employee>

I am stuck with Performance Problem where i need to join more than 8 tables, some are oneToOne association so i m left joining , some tables has more than 100 columns.

Can you please some one suggest the best way as i m using only jpa with hibernate and not using hibernate session directly.

_________________
Jana


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.