-
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.
SQL Struct with @lob (BLOB, CLOB) used as stored procedure parameter …
…type - fix (#1302) SQL Struct with @lob (BLOB, CLOB) used as stored procedure parameter type - fix Bugfix and unit test. Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
- Loading branch information
Showing
9 changed files
with
355 additions
and
23 deletions.
There are no files selected for viewing
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
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
80 changes: 80 additions & 0 deletions
80
...k.jpa.test/src/it/java/org/eclipse/persistence/testing/models/jpa/plsql/InnerObjBlob.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,80 @@ | ||
/* | ||
* Copyright (c) 2021 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 implementation | ||
package org.eclipse.persistence.testing.models.jpa.plsql; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.Lob; | ||
import org.eclipse.persistence.annotations.Struct; | ||
|
||
import java.util.Arrays; | ||
|
||
@Embeddable | ||
@Struct(name="PLSQL_P_PLSQL_INNER_BLOB_REC", fields={"BLOB_ID", "BLOB_CONTENT", "CLOB_CONTENT"}) | ||
public class InnerObjBlob { | ||
|
||
public InnerObjBlob() { | ||
} | ||
|
||
public InnerObjBlob(int blobId, byte[] blobContent, String clobContent) { | ||
this.blobId = blobId; | ||
this.blobContent = blobContent; | ||
this.clobContent = clobContent; | ||
} | ||
|
||
@Column(name="BLOB_ID") | ||
private int blobId; | ||
|
||
@Column(name="BLOB_CONTENT") | ||
@Lob | ||
private byte[] blobContent; | ||
|
||
@Column(name="CLOB_CONTENT") | ||
@Lob | ||
private String clobContent; | ||
|
||
public int getBlobId() { | ||
return blobId; | ||
} | ||
|
||
public void setBlobId(int blobId) { | ||
this.blobId = blobId; | ||
} | ||
|
||
public byte[] getBlobContent() { | ||
return blobContent; | ||
} | ||
|
||
public void setBlobContent(byte[] blobContent) { | ||
this.blobContent = blobContent; | ||
} | ||
|
||
public String getClobContent() { | ||
return clobContent; | ||
} | ||
|
||
public void setClobContent(String clobContent) { | ||
this.clobContent = clobContent; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "InnerObjBlob{" + | ||
"blobId=" + blobId + | ||
", blobContent=" + Arrays.toString(blobContent) + | ||
", clobContent='" + clobContent + '\'' + | ||
'}'; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...k.jpa.test/src/it/java/org/eclipse/persistence/testing/models/jpa/plsql/OuterObjBlob.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,62 @@ | ||
/* | ||
* Copyright (c) 2021 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 implementation | ||
package org.eclipse.persistence.testing.models.jpa.plsql; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import org.eclipse.persistence.annotations.Struct; | ||
|
||
@Embeddable | ||
@Struct(name="PLSQL_P_PLSQL_OUTER_STRUCT_REC", fields={"STRUCT_ID", "STRUCT_CONTENT"}) | ||
public class OuterObjBlob { | ||
|
||
public OuterObjBlob() { | ||
} | ||
|
||
public OuterObjBlob(int structId, InnerObjBlob structContent) { | ||
this.structId = structId; | ||
this.structContent = structContent; | ||
} | ||
|
||
@Column(name="STRUCT_ID") | ||
private int structId; | ||
|
||
@Column(name="STRUCT_CONTENT") | ||
private InnerObjBlob structContent; | ||
|
||
public int getStructId() { | ||
return structId; | ||
} | ||
|
||
public void setStructId(int structId) { | ||
this.structId = structId; | ||
} | ||
|
||
public InnerObjBlob getStructContent() { | ||
return structContent; | ||
} | ||
|
||
public void setStructContent(InnerObjBlob structContent) { | ||
this.structContent = structContent; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "OuterObjBBlob{" + | ||
"structId=" + structId + | ||
", structContent=" + structContent + | ||
'}'; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...pa.test/src/it/java/org/eclipse/persistence/testing/models/jpa/plsql/SaveComplexBlob.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,66 @@ | ||
/* | ||
* Copyright (c) 2021 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 implementation | ||
package org.eclipse.persistence.testing.models.jpa.plsql; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import org.eclipse.persistence.annotations.Direction; | ||
import org.eclipse.persistence.platform.database.oracle.annotations.*; | ||
|
||
@Entity | ||
@NamedPLSQLStoredFunctionQueries(value = { | ||
@NamedPLSQLStoredFunctionQuery(name = "PLSQL_BLOB_REC_IN", functionName = "PLSQL_P.PLSQL_BLOB_REC_IN", | ||
parameters = {@PLSQLParameter(name = "P_BLOB_REC", direction = Direction.IN, databaseType = "PLSQL_P_PLSQL_INNER_BLOB_REC"), | ||
@PLSQLParameter(name = "P_CITY", direction = Direction.IN, databaseType = "VARCHAR_TYPE")}, | ||
returnParameter = @PLSQLParameter(name = "RESULT", direction = Direction.OUT, databaseType = "VARCHAR_TYPE")), | ||
@NamedPLSQLStoredFunctionQuery(name = "PLSQL_STRUCT_INSTRUCT_REC_IN", functionName = "PLSQL_P.PLSQL_STRUCT_INSTRUCT_REC_IN", | ||
parameters = {@PLSQLParameter(name = "P_BLOB_REC", databaseType = "PLSQL_P_PLSQL_INNER_BLOB_REC"), | ||
@PLSQLParameter(name = "P_STRUCT_REC", databaseType = "PLSQL_P_PLSQL_OUTER_STRUCT_REC"), | ||
@PLSQLParameter(name = "P_CITY", databaseType = "VARCHAR_TYPE")}, | ||
returnParameter = @PLSQLParameter(name = "RESULT", direction = Direction.OUT, databaseType = "VARCHAR_TYPE")) | ||
} | ||
) | ||
@PLSQLRecords(value = { | ||
@PLSQLRecord(name = "PLSQL_P_PLSQL_INNER_BLOB_REC", compatibleType = "PLSQL_P_PLSQL_INNER_BLOB_REC", javaType = InnerObjBlob.class, | ||
fields = { | ||
@PLSQLParameter(name = "BLOB_ID", databaseType = "NUMERIC_TYPE"), | ||
@PLSQLParameter(name = "BLOB_CONTENT", databaseType = "BLOB_TYPE"), | ||
@PLSQLParameter(name = "CLOB_CONTENT", databaseType = "CLOB_TYPE") | ||
} | ||
), | ||
@PLSQLRecord(name = "PLSQL_P_PLSQL_OUTER_STRUCT_REC", compatibleType = "PLSQL_P_PLSQL_OUTER_STRUCT_REC", javaType = OuterObjBlob.class, | ||
fields = { | ||
@PLSQLParameter(name = "STRUCT_ID", databaseType = "NUMERIC_TYPE"), | ||
@PLSQLParameter(name = "STRUCT_CONTENT", databaseType = "PLSQL_P_PLSQL_INNER_BLOB_REC") | ||
} | ||
|
||
) | ||
} | ||
) | ||
public class SaveComplexBlob { | ||
|
||
@Id | ||
@Column(name = "RESULT") | ||
private String result; | ||
|
||
public String getResult() { | ||
return result; | ||
} | ||
|
||
public void setResult(String result) { | ||
this.result = result; | ||
} | ||
} |
Oops, something went wrong.