Hello,
I would like to use the NamedNativeQuery annotation as wrote in
CheatSheet model (
http://www.playframework.org/documentation/1.2.3/
cheatsheet/model) :
@NamedNativeQuery(name="q2","sql_query")
Defines a native SQL query for use in the persistence unit
Here my own code :
import javax.persistence.NamedNativeQuery;
(...)
@NamedNativeQuery(name="findByLastCommented", query="")
public class Table extends Model {
(...)
public List<Object> findByLastCommented() {
return
JPA.em().createNativeQuery("findByLastCommented").getResultList();
}
}
When I launch the Play! framework, I get the following Internal Server
Error:
JPA error
A JPA error occurred (Unable to build EntityManagerFactory): Pure
native scalar queries are not yet supported
play.exceptions.JPAException: Unable to build EntityManagerFactory
at play.db.jpa.JPAPlugin.onApplicationStart(JPAPlugin.java:
231)
at
play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:
425)
at play.Play.start(Play.java:495)
at play.Play.detectChanges(Play.java:610)
at play.Invoker$Invocation.init(Invoker.java:186)
at Invocation.HTTP Request(Play!)
Caused by: org.hibernate.cfg.NotYetImplementedException: Pure native
scalar queries are not yet supported
at
org.hibernate.cfg.annotations.QueryBinder.bindNativeQuery(QueryBinder.java:
140)
at
org.hibernate.cfg.AnnotationBinder.bindQueries(AnnotationBinder.java:
339)
at
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:
548)
at org.hibernate.cfg.Configuration
$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:
3977)
at org.hibernate.cfg.Configuration
$MetadataSourceQueue.processMetadata(Configuration.java:3931)
at
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:
1368)
at
org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345)
at
org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:
1477)
at
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:
193)
at
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:
1096)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:
900)
at play.db.jpa.JPAPlugin.onApplicationStart(JPAPlugin.java:
229)
... 5 more
Hmmm ... it's boring :'( There is a milestone for this feature ?
Thanks in advance.
Stan