-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate + Stored Procedure w output from Multiple tables
PostPosted: Thu Feb 18, 2010 5:32 pm 
Newbie

Joined: Thu Jan 28, 2010 5:13 pm
Posts: 4
Hi,

I have many stored procedures which are mostly 'get'. I am using Hibernate , Spring , Oracle for my application. Problem : I dont want to map the entity to any table in database as it used only for Stored Proc output. But i get error - org.hibernate.MappingException: Named query not known: notify
I think its because Hibernate did not load the entity ?? If i add @Entity to Entity class, i get error - org.hibernate.HibernateException: Missing table: Notify

NOTE: Hibernate doc AND most examples i found on net were same - stored procedure only for single table not multiple table.

My code has service layer which call DAO layer
Code:
return notificationDAO.sendNotify(runDate);


DAO implementation code has the following

Code:
   return (List<Notify>)getHibernateTemplate().execute(new HibernateCallback() {

         public Object doInHibernate(Session session) throws HibernateException, SQLException {
               return session.getNamedQuery("notify")
               .setParameter("runDate", runDate).list();
               
            
         }
      });


Code:
import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.annotations.NamedNativeQuery;
import javax.persistence.Entity;

import org.hibernate.annotations.GenericGenerator;
@Entity
@NamedNativeQuery(
      name = "notify",
      query = "{? = call notify(:runDate)}",
      resultClass=Notify.class,
      callable=true)
public class Notify implements Serializable{
   
   /**
    *
    */
   private static final long serialVersionUID = 1L;
   private Long id;
   private Long contractId;
   private String contractName;
   private Date transDate;
   private Long transAmt;
   private String crtUser;
   private String userName;
   
   @Id
   @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
   public Long getId() {
      return id;
   }
   public void setId(Long id) {
      this.id = id;
   }
   @Column(name="contract_id")
   public Long getContractId() {
      return contractId;
   }
   public void setContractId(Long contractId) {
      this.contractId = contractId;
   }
   @Column(name="contract_name")
   public String getContractName() {
      return contractName;
   }
   public void setContractName(String contractName) {
      this.contractName = contractName;
   }
   @Column(name="trans_date")
   public Date getTransDate() {
      return transDate;
   }
   public void setTransDate(Date transDate) {
      this.transDate = transDate;
   }
   @Column(name="trans_amt")
   public Long getTransAmt() {
      return transAmt;
   }
   public void setTransAmt(Long transAmt) {
      this.transAmt = transAmt;
   }
   @Column(name="current_user")
   public String getCrtUser() {
      return crtUser;
   }
   public void setCrtUser(String crtUser) {
      this.crtUser = crtUser;
   }
   @Column(name="user_name")
   public String getUserName() {
      return userName;
   }
   public void setUserName(String userName) {
      this.userName = userName;
   }


}


Thanks,
RockerRocker


Top
 Profile  
 
 Post subject: Re: Hibernate + Stored Procedure w output from Multiple tables
PostPosted: Fri Feb 19, 2010 10:08 am 
Newbie

Joined: Thu Jan 28, 2010 5:13 pm
Posts: 4
Anyone ?
Let me know if hibernate is the right choice to run stored procedures ?? (multiple table procedures)


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

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.