Native Queries in Netweaver 7.1
Hello Forum,
how do i convince the EntityManager that a select statement used for a native query is actually a select statement? I tried to issue an SQL statement starting with the keyword "select", containing a few parameters (i used a bare "?" to denote them, would this be correct?), a subselect, and some grouping operations, but upon calling getResultList(), the entity manager threw an Exception stating that the select statement was not a select statement.
Regards,
- Thomas
Rolf Paulsen wrote:
In native queries, according to the JPA spec, using positional parameters like :"?1", "?2",... is the only way to add parameters. Neither named parameters like ":foo" nor plain "?" are supported according to JPA 1.0 spec.
See JSR 220: Enterprise JavaBeansTM,Version 3.0, Java Persistence API, section 3.6.3 "Named parameters":
Only positional parameter binding may be portably used for native queries.
I only have (really good) experience with EclipsesLink where defining parameters in native queries works fine with ?1, ?2 like in the JPA spec. If in SAP JPA parameters in native queries must be defined in the query string using plain ?, it will not be compliant with the spec.
SAP JPA passes the SQL string specified in a native query raw (unparsed) to the database. This means that SAP JPA does make any assumption with respect to the syntax required by the underlying database with respect to paramter markers. In standard SQL, a plain ? character is used as a parameter marker. Standard SQL does not understand ?1 nor :foo.
The only binding mechanism for parameter values in native queries supported by SAP JPA is positional (as in alignment with the spec). Example
Query query = em.createNativeQuery("SELECT LAST_NAME FROM EMPLOYEE WHERE FIRST_NAME = ?");
query.setParameter(1, "Tim");
Rolf Paulsen wrote:
> And in SAP JPA NetWeaver 7.30, we do not get fully transparent lazy loading like in EclipseLink but a weaker form using cglib with EntitiyManager.getReference(): Whenever you need lazy loading, you have to hand-code it into your code.
This is a misundersanding. In 7.30, lazy loading of single-valued relationships is supported as an automatic mechanism. You do not need to programatically use getReference. However, as lazy loading of single-valued relationships has been introduced onyl with 7.30, you need enabled it explicitly in order to preserve a downward compatible behavior:
http://help.sap.com/saphelp_nw73/helpdata/en/68/f676ef36094f4381467a308a98fd2a/frameset.htm
-Adrian
Similar Messages
-
Parameter list in SQL native queries
I need to migrate from Toplink 10 to EclipseLink.
In my "old" project, I have some SQL native queries like '...... where field in #pFieldValues'
#pFieldValues is an arraylist/vector.
It was working perfectly with TopLink 10, but now it fails with 'Oracle Error' 'Invalid column type'.
How can I achieve this now with EclipseLink? (I don't want to use EJBQL queries (or JPQL queries).
ThanksI made it work modifying SQL statement for Access database by passing parametres in where clause.
But it works only for single value , though I have checked Allow multiple values: true. but fails when passing more than one value,
Error message pops up " Failed to retrive data from database. The Microsoft Access database engine could not find the object tblHirarchy('ANSTG', 'MCIS')
How to resolve it?
SELECT tbl_CBP.forcast_in_MON, tbl_CBP.forcast_MON, tbl_CBP.forcast_QTR,
tbl_Hierarchy.Technology_Group, tbl_Hierarchy.[Business_ Unit],
tbl_Hierarchy.Product_Family, tbl_CBP.Units, tbl_CBP.Cost, tbl_CBP.REV,
tbl_Time.Sort_order
FROM (tbl_Hierarchy INNER JOIN tbl_CBP ON tbl_Hierarchy.Product_Family =
tbl_CBP.PF) INNER JOIN tbl_Time ON tbl_CBP.forcast_MON =
tbl_Time.Fiscal_Month
where tbl_Hierarchy.Technology_Group = {?TG}
ORDER BY [sort_order]
union all
SELECT [Forcast_In_MON] & ' Actuals' AS forcast_In, tbl_Time.Fiscal_Month,
tbl_Time.Fiscal_Quarter, tbl_Hierarchy.Technology_Group, tbl_Hierarchy.
[Business_ Unit], tbl_Hierarchy.Product_Family, tbl_Actuals.Units,
tbl_Actuals.Cost, tbl_Actuals.REV, tbl_Time.Sort_order
FROM (tbl_Actuals INNER JOIN tbl_Hierarchy ON tbl_Actuals.PF =
tbl_Hierarchy.Product_Family) INNER JOIN tbl_Time ON tbl_Actuals.Actuals_MON
= tbl_Time.Forcast_In_MON
where tbl_Hierarchy.Technology_Group = {?TG}
ORDER BY [sort_order];
your HELP is highly appreciated. -
Start Transaction on native SAPGUI from Netweaver
Hello,
is it possible to connect to a native SAP GUI and start a Transaction (e.g. MD04) with the parameters plant and material from Netweaver 7.0 or 7.1?Hello,
thank you for your answers.
To be more exact:
We want to start a new SAP GUI for Windows Session on a Windows PC from a Webdynpro for Java Page (Netweaver 7.1).
Our Idea ist to hab a Link on the Webdynpro.
When the user uses this link a new SAP GUI for Windows Window is opening (with automatic Login and) with the excpected Transaction including the selected Parameters from the Webdynpro for Java Page. -
NOT Using Named Parameters in a Native Query
Hi!
like it is written in the Toplink JPA Extensions reference Toplink supports using named parameters in native queries.
See example from http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html:
Example 1-11 Specifying a Named Parameter With #
Query queryEmployees = entityManager.createNativeQuery(
"SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = #firstname"
queryEmployeeByFirstName.setParameter("firstName", "Joan");
Collection employees = queryEmployees.getResultList();
But I want to use "#" in the SQL statement so I want to disable this parameter binding somehow and let the query just execute the SELECT statement I deliver.
I have tried to add the property
<property name="toplink.jdbc.bind-parameters" value="false"/>
into the persistence.xml and I have also tried to add the query hint
query.setHint(TopLinkQueryHints.BIND_PARAMETERS, HintValues.FALSE);
but none of them prevents the # to be uses as a paramter. this causes the exception:
Exception [TOPLINK-6132] (Oracle TopLink Essentials - 9.1 (Build b22)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Query argument ######' not found in list of parameters provided during query execution.
Query: ReadAllQuery(de.merck.compas.material.SimilarLocalMaterialListItemBV)
The SQL Statement is
SELECT * FROM TABLE (
CAST ( RCGC.PHA_P_COMPASMDM.LookupSimilarMats
( 'COC003','10021500150000000997','30','30','040','standard','','001001','001001','123456','##########','X','X','X','X','U' )
AS RCGC.PHA_COMPAS_SIMILAR_MATS ) )
I am using the latest Toplink essentials build together with an Oracle 9.2i DB in a Java SE web application.
Can anyone give me a little hint what to do?
Thanks and best regards,
AlexI hope this is what you need:
[TopLink Fine]: 2007.01.19 02:56:48.278--ServerSession(17712783)--Connection(723185)--Thread(Thread[http-8080-Processor2
3,5,main])--SELECT APPL_CGP_MATLOC, CHANGE_REQ_MATLOC, CD_PHA_MAT_LOC, LCOMP, LOC_MAT_NAME, APPL_GDM_MATLOC, LOC_MAT_NAM
E_SHORT, APPL_PDW_MATLOC, PHA_MAT_LOC_LCOMMENT, APPL_TP_MATLOC, DIVISION, APPL_WRS_MATLOC, ARTICLE_ID_MDA, LU_PHA_MAT_LO
C, LOC_MAT_NAME_OLD, LDT_PHA_MAT_LOC, PHA_MAT_LOC_STATUS, CU_PHA_MAT_LOC, MAT_LOC_ID, RCOMP, MAT_ID FROM RCGC.PHA_V_COMP
AS_MAT_MATLOC WHERE ((MAT_LOC_ID = '123456') AND (RCOMP = '001001'))
[TopLink Fine]: 2007.01.19 02:56:48.398--ServerSession(17712783)--Connection(32404901)--Thread(Thread[http-8080-Processo
r23,5,main])--SELECT MAT_ID, DESCRIPTION, PHA_MATERIAL_LCOMMENT, PACKSIZE, LU_PHA_MATERIAL, PACKSIZE_UNIT, LDT_PHA_MATER
IAL, CONTAINER_NAME, CU_PHA_MATERIAL, PURPOSE, CD_PHA_MATERIAL, CONTENT, CONTAINER_ID, AI_FACTOR, PHA_MATERIAL_STATUS, C
MG_SPEC_APP, PROD_LEVEL, PACKAGE_SIZE, PRODUCT_ID FROM RCGC.PHA_V_COMPAS_MATERIAL WHERE (MAT_ID = '10021500150000000997'
[TopLink Fine]: 2007.01.19 02:56:48.468--ServerSession(17712783)--Connection(723185)--Thread(Thread[http-8080-Processor2
3,5,main])--SELECT PRODUCT_ID, PROD_GRP_ID, APPL_FORM_NAME, PRODUCT_NAME, GALENIC_FORM_NAME, APPL_FORM_ID, PHA_PRODUCT_S
TATUS, PHA_PRODUCT_LCOMMENT, GALENIC_FORM_ID, LU_PHA_PRODUCT, INN, LDT_PHA_PRODUCT FROM RCGC.PHA_V_COMPAS_PRODUCT WHERE
(PRODUCT_ID = 'COC003')
[TopLink Fine]: 2007.01.19 02:56:48.568--ServerSession(17712783)--Connection(32404901)--Thread(Thread[http-8080-Processo
r23,5,main])--SELECT APPL_CGP_MATLOC, CHANGE_REQ_MATLOC, CD_PHA_MAT_LOC, LCOMP, LOC_MAT_NAME, APPL_GDM_MATLOC, LOC_MAT_N
AME_SHORT, APPL_PDW_MATLOC, PHA_MAT_LOC_LCOMMENT, APPL_TP_MATLOC, DIVISION, APPL_WRS_MATLOC, ARTICLE_ID_MDA, LU_PHA_MAT_
LOC, LOC_MAT_NAME_OLD, LDT_PHA_MAT_LOC, PHA_MAT_LOC_STATUS, CU_PHA_MAT_LOC, MAT_LOC_ID, RCOMP, MAT_ID FROM RCGC.PHA_V_CO
MPAS_MAT_MATLOC WHERE (MAT_ID = '10021500150000000997')
[TopLink Warning]: 2007.01.19 02:56:48.638--UnitOfWork(4469532)--Thread(Thread[http-8080-Processor23,5,main])--Exception
[TOPLINK-6132] (Oracle TopLink Essentials - 9.1 (Build b22)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Query argument ######' not found in list of parameters provided during query execution.
Query: ReadAllQuery(de.merck.compas.material.SimilarLocalMaterialListItemBV)
Local Exception Stack:
Exception [TOPLINK-6132] (Oracle TopLink Essentials - 9.1 (Build b22)): oracle.toplink.essentials.exceptions.QueryExcept
ion
Exception Description: Query argument ######' not found in list of parameters provided during query execution.
Query: ReadAllQuery(de.merck.compas.material.SimilarLocalMaterialListItemBV)
at oracle.toplink.essentials.exceptions.QueryException.namedArgumentNotFoundInQueryParameters(QueryException.jav
a:206)
at oracle.toplink.essentials.internal.databaseaccess.DatasourceCall.getValueForInParameter(DatasourceCall.java:6
86)
at oracle.toplink.essentials.internal.databaseaccess.DatasourceCall.getValueForInOutParameter(DatasourceCall.jav
a:704)
at oracle.toplink.essentials.internal.databaseaccess.DatasourceCall.translateQueryString(DatasourceCall.java:630
at oracle.toplink.essentials.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:850)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQuer
yMechanism.java:212)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQuer
yMechanism.java:199)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCa
llQueryMechanism.java:270)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQu
eryMechanism.java:600)
at oracle.toplink.essentials.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:302)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:
709)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:677)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:7
31)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2218)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:346)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:447)
at de.merck.compas.material.SimilarLocalMaterialListItemBC.selectList(SimilarLocalMaterialListItemBC.java:40)
at de.merck.compas.material.SimilarLocalMaterialListItemBC.selectSimilar(SimilarLocalMaterialListItemBC.java:53)
at de.merck.compas.material.MaterialMaintainFS.init(MaterialMaintainFS.java:158)
at de.merck.compas.material.MaterialListSV.startMaterialMaintain(MaterialListSV.java:186)
at de.merck.compas.material.MaterialListSV.processPage(MaterialListSV.java:97)
at de.merck.jsfw.servletFramework.AbstractServlet.processPage(AbstractServlet.java:141)
at de.merck.jsfw.servletFramework.ControllerServlet.processLastPage(ControllerServlet.java:240)
at de.merck.jsfw.servletFramework.ControllerServlet.processRequest(ControllerServlet.java:206)
at de.merck.jsfw.servletFramework.ControllerServlet.doGet(ControllerServlet.java:181)
at de.merck.jsfw.servletFramework.ControllerServlet.doPost(ControllerServlet.java:191)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at de.merck.comp.ntml.NTLMFilter.negotiate(NTLMFilter.java:384)
at de.merck.comp.ntml.NTLMFilter.doFilter(NTLMFilter.java:165)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java
:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
The Toplink manifest file with version number:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_09-b03 (Sun Microsystems Inc.)
Specification-Title: Java Persistence API
Specification-Vendor: Sun Microsystems, Inc., Oracle Corp.
Specification-Version: 1.0
Implementation-Title: TopLink Essentials
Implementation-Vendor: Sun Microsystems, Inc., Oracle Corp.
Implementation-Version: 9.1 build: b22
Thanks again for your help! -
Named Parameters in Queries - the spec vs the Java EE 5 Tutorial
Hi,
I've been studying the topic about the named parameters in JPA and found one inconsistency between the spec and the Java EE 5 Tutorial. Could anyone lend me a helping hand understanding it?
The Java Persistence API spec (ejb-3_0-fr-spec-persistence.pdf) 3.6.3 "Named Parameters" at page 69 reads:
The use of named parameters applies to the Java Persistence query language, and is not defined for native queries.
whereas the Java EE 5 Tutorial in the section Named Parameters in Queries (http://java.sun.com/javaee/5/docs/tutorial/doc/PersistenceIntro3.html#wp81563) of The EntityManager reads:
Named parameters are case-sensitive, and may be used by both dynamic and static queries.
I think that the reality is that every JPA provider supports named parameters in dynamic and static queries, but it's not fully supported by the spec (yet not forbidden).
Jacek
Jacek Laskowski
http://www.jaceklaskowski.plHi Jacek,
These are not conflicting statements. Named parameters apply to the Java Persistence
Query language only, not to native queries. There are two ways to specifiy
Java Persistence Query Language queries : dynamically and statically. You can
either pre-define the query string using @NamedQuery
static :
@NamedQuery(name="findPersonByName",
query="SELECT OBJECT(p) FROM Person p WHERE p.name LIKE :pName")
OR, pass the query string in at runtime using EntityManger.createQuery
dynamic :
em.createQuery("SELECT OBJECT(p) FROM Person p WHERE p.name LIKE :pName")
The dynamic approach allows you to construct portions of the query string at runtime.
My example doesn't do that but the point is that use of the createQuery()
API is considered the dynamic approach.
The crux of the Java EE 5 Tutorial statement you referenced is that named parameters apply to
both the static and dynamic use of Java Persistence Query Language queries.
--ken -
Hello.
I'm using some native queries in my EJB 3.0 project.
When I write a native query like
INSERT INTO SOME_TABLE VALUES (:val0, :val1, :val2) and use the executeUpdate() method of the Query interface after assigning all parameters to values other than null everything works OK.
However, if I let any of the values be null (even though that exactly what I want to put in the database) I get the following exception:
java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
Is there any way to go arround this? I really must write the nulls to the database.
Thanks in advance,
Hugo Oliveira
[email protected]Do you mean writing a query like
"INSERT INTO SOME TABLES VALUES :val0, NULL, :val2"
instead of
"INSERT INTO SOME TABLES VALUES :val0, :val1, :val2"
where the val1 parameter would be assigned a null variable, or passing a null directly in setParameter (query.setParameter("val1", null)) instead of a null variable (query.setParameter("val1", nulVar))?
Hugo Oliveira
[email protected] -
Suppress Power Query's Native Database Query Warning
Is there a way to suppress the "Native Database Query" warning issued by Power Query when running a SQL query directly against a Teradata database? This warning states, "You are about to run a native database query. Native queries
can make changes to the database. Would you like to run the following query?"If we never prompted here, then I could send you a workbook with the embedded query "drop table foo". You'd open it, Power Query would run analysis and we'd execute the statement -- all before you had any idea what had happened. It's true that
there are many potential users for whom showing the SQL text isn't useful. Hopefully, those users don't have the kinds of server permission that would let a query run with their credentials do lasting damage. But the prompt is to deal with the very possible
risk of having even a sophisticated user run a query by accident that they shouldn't have.
The original intent of the feature was to support a scenario where a user says "I already have a SQL query whose output I want to consume into Power Query; why can't I just use that?" It did not take parameterization into account. We subsequently
considered adding parameterization to this method, but didn't feel that we could sufficiently guarantee security. That is, if your query text is Sql.Database("server", "database", [Query="exec @sql", Parameters=[sql="drop
table foo"]], the user would be prompted only with "exec @sql" and the malicious payload would be delivered invisibly.
We very much do not want to have the responsibility of parsing multiple different dialects of SQL to try to guess whether or not it contains potentially-malicious code.
Our current thinking on this is that we might let advanced users write "trusted code" which has to go through a separate verification step. Code of this type might be able to generate SQL statements without a user prompt. So a workbook might have
a dependency on the "My Trusted Code" module, and simply won't run if that module hasn't been installed on the local machine. The user would then need a trustworthy (but convenient) way to obtain that module from a trustworthy source. -
Will Kodo EJB3 support SQL queries standard?
Hello,
Will Kodo EJB3 support SQL queries (via
EntityManager.createNativeQuery(...))
in the Standard Edition since native queries are part of the API? Or will
that functionality require Enterprise Edition or Performance Pack?
thanks and good luck in the new year,
daveCurrently, SQL queries require the enterprise edition. Whether this
will change for Kodo 4 final has not been decided. The safest route
would be to assume that it will not change. -
Data Refesh does not support script only queries
I created a Power Query transformation that does not contain any data source because it generates a fixed table (imagine a Date Table, with certain columns marked based on current day value). I receive this alert trying to create the data source:
Discover data sources - You can only use a connection string that has SQL Server or Oracle data sources. Also, the data sources cannot include native queries. Tracing ID: 040eda49-bcf9-4c82-af1c-69f6efb26cd0 - 07.55.44
The refresh fails with this error:
Failure
Correlation ID:
10225488-17be-4256-b03e-be975b87a281
OnPremise error: Sorry, we can't refresh connections to this kind of data source in Power Query yet.
I am wondering whether I can workaround the check by creating a SQL Query that returns an empty table that will be ignored in a following join, but is that really necessary? Why not refreshing a transformation that doesn't access to any data source?
Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russoI tried to workaround the issue using the script below. However, even if creating the Data Source in Data Management Gateway worked well, without raising any error, I had this error (script follows).
Is the Table.Combine limited? Or what is the issue in this case?
Thanks!
Marco
Scheduled start time: 5/3/2014 1:58 PM
Actual start time: 5/3/2014 2:31 PM
Failure time: 5/3/2014 2:31 PM
Status:
Failure
Correlation ID: 3abb39be-05df-40e5-8366-45bdf58ccdc3
Data connections status:
Power Query - DimProductCategory
OnPremise error: Sorry, we can't refresh connections to this kind of data source in Power Query yet.
Report owner: Marco Russo
let
Tab1 = #table( {"Number"}, { {1}, {2}, {3}, {4}, {5} } ),
Source = Sql.Database("servername", "AdventureWorksDW2012"),
dbo_DimProductCategory = Source{[Schema="dbo",Item="DimProductCategory"]}[Data],
FilteredRows = Table.SelectRows(dbo_DimProductCategory, each [ProductCategoryKey] = 0),
InsertedCustom = Table.AddColumn(FilteredRows, "Number", each 0),
RemovedColumns = Table.RemoveColumns(InsertedCustom,{"ProductCategoryKey", "ProductCategoryAlternateKey", "EnglishProductCategoryName", "SpanishProductCategoryName", "FrenchProductCategoryName", "DimProductSubcategory"}),
Append = Table.Combine({RemovedColumns,Tab1 })
in
Append
Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo -
I am a new comer to the field of SAP Netweaver for Voice. Pls suggest some useful demos or links for this field. Also let me know if there is an existing forum for the same.
Hi,
<b>SAP Help on NetWeaver Voice</b>
http://help.sap.com/saphelp_nwce10/helpdata/en/45/51b6418a853bdce10000000a1553f7/frameset.htm
<b>Developing Voice Applications with the SAP NetWeaver Voice (Session ID = UPE105 at TechEd '06)</b>
http://www.sapteched.com/06/usa/edu_sessions/session.htm?sid=152
<b>SAP's tool for developing Voice Application in NetWeaver</b>
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/eac9cf35-0801-0010-918b-ab231eba0bd0
Currently there are no particular form for NW Voice, but you can put your queries under NetWeaver Platform or Visual Composer or Portal.
Regards
Nilay -
Using of @SqlResultSetMapping
Hello,
I try to use mapping for native queries. My code is(entities are created with JDeveloper wizard's help as "Entity from Table"):
Levels.java:
@SqlResultSetMappings({
@SqlResultSetMapping(name="findAllLvlDscFull",
entities={@EntityResult(entityClass=Levels.class),
@EntityResult(entityClass=Descriptions.class)}),
@SqlResultSetMapping(name="findAllLvlDscNames",
columns={@ColumnResult(name="lvl_name"),
@ColumnResult(name="dsc_name")})
@Entity
public class Levels implements Serializable {
private Long id;
private String name;
private Descriptions descriptions;
public Levels() {
@Id
@Column(nullable = false)
public Long getId() {
return id;
public void setId(Long id) {
this.id = id;
@Column(nullable = false)
public String getName() {
return name;
public void setName(String name) {
this.name = name;
@ManyToOne
@JoinColumn(name = "DSC_ID", referencedColumnName = "ID")
public Descriptions getDescriptions() {
return descriptions;
public void setDescriptions(Descriptions descriptions) {
this.descriptions = descriptions;
Description.java:
@Entiy
public class Descriptions implements Serializable {
private String description;
private Long id;
private List<Levels> levelsList;
public Descriptions() {
public String getDescription() {
return description;
public void setDescription(String description) {
this.description = description;
@Id
@Column(nullable = false)
public Long getId() {
return id;
public void setId(Long id) {
this.id = id;
@OneToMany(mappedBy = "descriptions")
public List<Levels> getLevelsList() {
return levelsList;
public void setLevelsList(List<Levels> levelsList) {
this.levelsList = levelsList;
For first SqlResultSetMapping I use below code - it works nice.
Query query = em.createNativeQuery("SELECT * FROM LEVELS lvl, DESCRIPTIONS dsc WHERE"+
" lvl.dsc_id = dsc.id", "findAllLvlDscFull");
List resultList = query.getResultList();
For second SqlResultSetMapping I use such code:
Query query = em.createNativeQuery("SELECT lvl.name lvl_name, dsc.description dsc_name FROM LEVELS lvl, DESCRIPTIONS dsc WHERE"+
" lvl.dsc_id = dsc.id", "findAllLvlDscFull");
It doesn't work: I get such error
Exception [TOPLINK-6044] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRecord(
LEVELS.ID => null
LEVELS.NAME => null
LEVELS.DSC_ID => null)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ResultSetMappingQuery(com.desyde.tms.model.entity.Levels)
The same error I get every time I want to use aliases for fields:
@SqlResultSetMapping(name="findAllDsc",
entities={@EntityResult(entityClass=Descriptions.class,
fields={@FieldResult(name="id", column="dsc_id"),
@FieldResult(name="description", column="dsc_name")})
Query query = em.createNativeQuery("SELECT dsc.id AS dsc_id, dsc.description AS dsc_name FROM DESCRIPTIONS dsc", "findAllDsc");
List list = query.getResultList();
Could somebody give an advice how to solve this problem?
Thanks in advance.Is anyone using ResultSetMapping? How do U implement mapping for NativeQueries(with aliases and set of data from several tables via @ColumnResults and @FieldResults)?(I've tried to do it in JDev 10.1.3.1 - have got above problems)
-
Oracle query hints in JPQL - is it possible?
Sorry, posted to wrong forum... I don't know how to delete it - only edit...
Hello,
I am using Sun Java Application Server 9.1 (GlassFish), EJB 3.0 and JPA (TopLink). My database is Oracle.
Is there any way to specify Oracle query hints (for example, /*+ rule */ in JPQL queries? Or the only way to do it is using native queries?
Many thanks in advance
Edited by: Troff_2 on Nov 27, 2007 5:50 AMYes.It is possible.Only need to modify the view for order tracker query need to change.
You can use decode statement in the query to add status as Processing .
Please refer the IBE_ORDER_SUM_V view for details.
Eg:
decode(oel.meaning,'Booked',"Processing",oel.meaning) from
oe_lookups
oel, -
SAP JPA - case-insensitive search
Hi there, is it possible to have a case-insensitive search with SAP JPA? The keywords UPPER, LOWER aren't available in the query (OpenSQL limitation I guess).
The only way I see is to create a duplicates columns for the search relative atributes and make the data upper or lower case before save. May be there is another options? More suitable and elegant?Hi,
you may bypass openSQL by native queries.
Make sure that you use the hint described in
http://help.sap.com/saphelp_nwce72/helpdata/en/4a/0cf02870c540caab611d56220ec0cb/frameset.htm
together with createNativeQuery.
But anyway, the approach with duplicates columns enables you to create indexes on these UPPER columns. It is not too bad.
Regards,
Rolf -
Hi,
I have a JPQL like..
select o from objectClass o where o.dateField : P_DATE
And the query don't returns nothing.
The types of variables are java.sql.Date, my _DB is Oracle 10.
If I look the server console i get the transformed SQL, someting like
SELECT * FROM tableMapping t WHERE t.dateField = ?
If I put a TRUNC in my parameter, its works fine.
So.. How make this in my JPQL?
Any IdeaSome of these other options may also work:
*) If you don't need the time component persisted on inserts/updates, then ensure that the date in the table is truncated:
If using INSERT DML, then it would look like:
INSERT INTO ...(..., <DATE_COLUMN>, ...)
VALUES (..., TRUNC(<DATE_VALUE>), ...).
If using UPDATE DML, then it should look like:
UPDATE ...
SET ..., <DATE_COLUMN> = TRUNC(<DATE_VALUE>), ...
If using EJB merge or persist, then it would look like:
TMorosidadAclaracion acl = new TMorosidadAclaracion();
java.sql.Date dateValue = ...;
<Truncate dateValue Here>
acl.setMoaFecpago(dateValue);
em.persist(acl); // Or em.merge(acl) if merging.
*) If you need the time component persisted on inserts/updates, then native queries are another option. With a native query, you can use the TRUNC function.
*) If you need the time component persisted on inserts/updates, then querying with a view is another option; in your view, you would use "TRUNC(<DATE_VALUE>)" instead of just "<DATE_VALUE>". In my system, I have created entities that point to views for query purposes. -
To make a join query of two or more tables from database I wrote a native query and execute that query.
Th entity manager is obtained from a container managed session facade.
The tables at database are like
table A(column1, column2, column3)
table B(column4, column5, column6)
the native query is like this
select a.column1 as c1,
a.column2 as c2,
a.column3 as c3,
b.column4 as c4,
b.column5 as c5,
b.column6 as c6
from A a, B b where a. column1 = b.column4
and the result entity class like this
public class JoinQueryResult{
private String c1;
private String c2;
private String c3;
private String c4;
private String c5;
private String c6;
// getters and setters here
and executing the query like
Query q = entityManager.createNativeQuery(sql,JoinQueryResult.class);
List<JoinQueryResult> = q.getResultList();
when I want to set c6 attribute of one instance of JoinQueryResult the entity manager automatically want to update the entity of JoinQueryResult and gets an error saying there is no table JoinQueryResult .
This is not the real table. I want just get the result of this join query to java beans.
What is the solution or best way to this method.
There must be way for example saying entity mnager do not persist this entity because it is just the result of native query.
Or could you plese say a solution method for this situation
best regardsHello,
I can't say which is best, but there are a number of options.
You can either throw away the EntityManager or clear it once you've read your data (to make all the entities detached), or make all the fields in the Entity insertable=false, updatable=false ie:
@Entity
public class JoinQueryResult{
@Column(insertable=false, updatable=false )
private String c1;
}If you already have tables A and B mapped to Entities (say EntityA and EntityB) you can do the same thing in JPA but it won't require JoinQueryResult to be an entity - you can use a constructor in a jpa query. For instance:
createQuery("Select new package.JoinQueryResult( a.c1, a.c2, a.c3, b.c4, b.c5, c.c6) from EntityA a, EntityB b, where a.c1=b.c4");
The returned joinQueryResult objects would then not be managed, but it assumes you have Entities for the A and B tables, and that the JoinQueryResult has a constructor to take in all values.
Not related to getting readonly data, but you can also map the Entity in such a way to not require native queries, but having your JoinQueryResult map to tables A and B
@Table(name="A")
@SecondaryTable(name="B",
pkJoinColumns=@PrimaryKeyJoinColumn(name="column4"))
public class JoinQueryResult{
@Column(name="column1")
private String c1;
Maybe you are looking for
-
Unable to WDS install Win 8.1 VM on Hyper-V 2012 R2
Hi. We've recently gone from Server 2008 R2 (Data Center) to Windows 2012 R2 (Data Center) and we're now trying to install Windows 8.1 clients on our Hyper-V solution. When using the virtual machine creation wizard I create two test machines. One mac
-
How do i get my code to be applicable in a certain case only
Greetings ABAPers. I would like to know the various ways in which i can get my code to be applicable in a certain case. Ive include the code below. I want the code to execute only when the object type is 'BP' for business partner. That is, i want my
-
Premiere CS5 (win7 x64) won't recognize my Mini-DV camcorder.
I have Premiere Pro CS5 installed on a Windows 7 64-bit system. When I try to Capture, I keep getting the error message: "Can't Activate Recorder. Try Resetting Camera." the whole set-up worked fine on my XP system with Premiere Pro 1.5. Extra info
-
Error in a page with a master-detail:Unable to resolve a Validator instance
Hi all, I am using Jdeveloper 11.1.1.2 I have a page with a master table and a detail table. When I try to select a row in the some tables (master or detail), I have this error: <AbstractValidatorTag><createValidator> Unable to resolve a Validator in
-
iPad 2 with new OS has been operating fine for a month. worked perfectly last night. woke up this morning to "iPad Disabled". can i get it back? how? is every single document, contact, note, business email, song and photo stored and recoverable from