JPA NamedNativeQuery with Play! isn't yet supported ?

440 views
Skip to first unread message

Stan

unread,
Nov 10, 2011, 4:11:08 AM11/10/11
to play-framework
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

leo hu

unread,
Nov 10, 2011, 4:48:06 AM11/10/11
to play-fr...@googlegroups.com
where is your native sql ? 

Pls check the following code :

@Entity
@Table(name = "EMP")
@NamedNativeQuery(name = "nativeSQL", query = "SELECT emp1.emp_id, emp1.name, emp1.manager_id, "
    "emp1.dept_id, emp1.address_id " "FROM EMP emp1, EMP emp2 "
    "WHERE ((emp2.EMP_ID = ?) AND (emp2.EMP_ID = emp1.MANAGER_ID))", resultClass = Professor.class)
public class Professor 
{






Stan

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.


Reply all
Reply to author
Forward
0 new messages