-->
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: problem with stored procedures and annotations
PostPosted: Mon Jun 22, 2009 1:00 pm 
Newbie

Joined: Tue Dec 16, 2008 6:59 am
Posts: 6
Hi
I am using Hibernate Annotations Version: 3.3.0.GA (as seen in MANIFEST.MF) to annotate entity classes. Now, I want to be able to call an stored procedure which returns just an integer value (actually, this is to check some value and return 0 o 1 depending on the check is successful or not).

Well, I have the following code to declare the stored procedure, actually a function, and be able to call it from my program:
Code:
@NamedNativeQuery(name="checkValue", callable=true,
      query="? = call checkValue (:myvalue)",
      resultClass = Integer.class)


This annotation is in the top of an entity class, and when hibernate is setting the configuration for the annotated classes (at startup time) I get this exception:
Code:
2009-06-22 18:47:39,010 ERROR SessionFactoryImpl.<init>:363 - Error in named query: checkValue
org.hibernate.MappingException: Unknown entity: java.lang.Integer
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
   at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.getSQLLoadable(SQLQueryReturnProcessor.java:312)
   at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processRootReturn(SQLQueryReturnProcessor.java:353)
   at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:332)
   at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:148)
   at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:64)
   at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
   at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
   at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:446)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
   at (...)



I have been searching on internet but I didn't get anything more or less clear about this problem.
May I actually use stored functions or procedures and call them from hibernate? Does hibernate support stored functions returning just scalar values? Do I have anything wrong in the declaration?

The only example with scalars I have found is on the annotations tutorial but it is quite unuseful for me as they don't use a true stored function.

Thanks in advance and apologies if this is a fool question.

w i l l y


Top
 Profile  
 
 Post subject: Re: problem with stored procedures and annotations
PostPosted: Tue Sep 01, 2009 8:45 am 
Beginner
Beginner

Joined: Sun Aug 13, 2006 8:40 am
Posts: 28
This is an interesting issue. I am also looking on how to call existing stored procedures that only return an integer with Hibernate.

I would be thankful for all help given :)

Thanx


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.