-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oracle NoSQL Database - NativeQueries and more complex JPA queries su…
…pport (#1793) This change brings into EclipseLink and Oracle NoSQL Database platform support for: JPA @NamedNativeQuery support for more complex Jakarta Persistence queries like SELECT t FROM DataTypesEntity t WHERE t.id = :id AND t.fieldString = :name Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
- Loading branch information
Showing
7 changed files
with
265 additions
and
49 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...nosql/src/it/java/org/eclipse/persistence/testing/models/jpa/nosql/NativeQueryEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.models.jpa.nosql; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.NamedNativeQuery; | ||
import jakarta.persistence.Table; | ||
|
||
import org.eclipse.persistence.nosql.annotations.DataFormatType; | ||
import org.eclipse.persistence.nosql.annotations.NoSql; | ||
|
||
@Entity | ||
@Table(name = "TEST_TAB") | ||
@NamedNativeQuery( | ||
name="NativeQueryEntity.findByIdSQLNativeQueryEntity", | ||
query="DECLARE $id INTEGER; SELECT $tab.id, $tab.col_json_object.map[$element.m1 = 5] as component FROM TEST_TAB $tab WHERE id = $id", | ||
resultClass= org.eclipse.persistence.testing.models.jpa.nosql.NativeQueryEntity.class | ||
) | ||
//@NoSql -> it's not possible to use default (dataFormat= DataFormatType.XML) as QueryStringInteraction which is behind @NamedNativeQuery extends MappedInteraction not XMLInteraction | ||
@NoSql(dataFormat= DataFormatType.MAPPED) | ||
public class NativeQueryEntity { | ||
@Id | ||
private long id; | ||
@Column(name = "component", columnDefinition = "JSON") | ||
private String component; | ||
|
||
public NativeQueryEntity() { | ||
} | ||
|
||
public NativeQueryEntity(long id) { | ||
this.id = id; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getComponent() { | ||
return component; | ||
} | ||
|
||
public void setComponent(String component) { | ||
this.component = component; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NativeQueryEntity{" + | ||
"id=" + id + | ||
", component='" + component + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.