Possible Duplicate:
Calling a Stored Procedure in Hibernate
I have the following problem: I can not call a stored procedure in java
what I did was this:
create a class that implements serializable semaforoBO call and add the following
@Entity
@NamedNativeQuery(
name="CalculoSemaforo",
query = "exec CalculoSemaforo codigo,fecha",
callable=true,
resultClass=char.class
)
public class SemaforoBO implements Serializable{
//code
}
the name of the stored procedure is CalculoSemaforo and has two input variables returning a char. Then within SemaforoBO there a function that does the following:
public char semaforo(){
DBTenant dbTenant = new DBTenant();
Session sess;
try {
sess = dbTenant.getTenantSession();
Query query =sess.getNamedQuery("CalculoSemaforo");
query.setString("codigo", this.codigoarticulo);
query.setLong("fecha",this.fecha);
sem = (Character) query.uniqueResult();
}
catch(NullPointerException e)
{
sem = 'x';
}
return sem;
}
but it gives me a excepccion org.hibernate.MappingException: Named query not known: CalculoSemaforo
any idea how this solution Thanks