users@glassfish.java.net
Re: How to write native sql in orm.xml?
This message
: [
Message body
] [ More options (
top
,
bottom
) ]
Related messages
: [
Next message
] [
Previous message
] [
In reply to
]
Contemporary messages sorted
: [
by date
] [
by thread
] [
by subject
] [
by author
] [
by messages with attachments
]
From
: <
glassfish_at_javadesktop.org
>
Date
: Sun, 01 Jul 2007 22:06:35 PDT
Hi:
You can write native sql queries in orm.xml. Here's an example:
<entity class="entities.NoNamedNativeQueryAnnotation" >
<named-native-query name="NamedNativeQueryFromXML" result-set-mapping="CountBananas">
<query>Select m.ID AS "ID" , m.NAME AS "NAME" from NONAMEDNATIVEQUERYANNOTATION m where m.NAME='Banana'</query>
</named-native-query>
<sql-result-set-mapping name="CountBananas">
<entity-result entity-class="entities.NoNamedNativeQueryAnnotation" />
</sql-result-set-mapping>
</entity>
This above example is named such that it indicates non-existence of the NamedNativeQuery annotation in the Entity.
NamedNativeQuery annotations can also be overridden by the entries in orm.xml. For overridding rules see chapter 10.1 of specification at
http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html
.
For more information on how to create named native queries use the orm schema at
http://java.sun.com/xml/ns/persistence/
and chapter 8.3 of the specification.
If you are using glassfish (
https://glassfish.dev.java.net/public/downloadsindex.html
) watch out for issues described at
-
https://glassfish.dev.java.net/issues/show_bug.cgi?id=2046
-
https://glassfish.dev.java.net/issues/show_bug.cgi?id=1968
(this is not a complete list of issues - search for other possible glassfish related issues with named-native-queries or sql-result-set-mappings at
https://glassfish.dev.java.net/servlets/ProjectIssues
)
thanks.
varun.
[Message sent by forum member 'vr143562' (vr143562)]
http://forums.java.net/jive/thread.jspa?messageID=224854
This message
: [
Message body
]
Next message
:
Sahoo: "Re: Building Toplink Essentials Howto"
Previous message
:
glassfish_at_javadesktop.org: "Re: Two JTA persistance units does not see each other changes, why?"
In reply to
:
glassfish_at_javadesktop.org: "How to write native sql in orm.xml?"
Contemporary messages sorted
: [
by date
] [
by thread
] [
by subject
] [
by author
] [
by messages with attachments
]