Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Issue 1779: Add DB2zOS support for UNICODE Timestamps #1782

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022 IBM Corporation. All rights reserved.
* Copyright (c) 2015, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023 IBM Corporation. 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
Expand Down Expand Up @@ -56,6 +56,7 @@
import org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField;
import org.eclipse.persistence.platform.database.converters.StructConverter;
import org.eclipse.persistence.queries.StoredProcedureCall;
import org.eclipse.persistence.queries.ValueReadQuery;

/**
* <b>Purpose</b>: Provides DB2 z/OS specific behavior.
Expand Down Expand Up @@ -112,6 +113,25 @@ public String getProcedureOptionList() {
return " DISABLE DEBUG MODE ";
}

/**
* INTERNAL:
* This method returns the query to select the timestamp from the server for
* DB2.
*/
@Override
public ValueReadQuery getTimestampQuery() {
if (timestampQuery == null) {
if (getUseNationalCharacterVaryingTypeForString()) {
timestampQuery = new ValueReadQuery();
timestampQuery.setSQLString("SELECT CAST (CURRENT TIMESTAMP AS TIMESTAMP CCSID UNICODE) FROM SYSIBM.SYSDUMMY1");
timestampQuery.setAllowNativeSQLQuery(true);
} else {
timestampQuery = super.getTimestampQuery();
}
}
return timestampQuery;
}

/**
* INTERNAL:
* Initialize any platform-specific operators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 IBM Corporation. All rights reserved.
* Copyright (c) 2022, 2023 IBM Corporation. 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
Expand Down Expand Up @@ -3191,7 +3191,7 @@ public void testLocate1_PartialBind() {
query.getResultList();
Assert.assertEquals(1, _sql2.size());
if(platform.isDB2Z()) {
Assert.assertEquals("SELECT INTVAL1 FROM QUERYSYNTAXENTITY WHERE (INTVAL1 = LOCATE('HI', 'ABCDEFGHIJKLMNOP'))", _sql.remove(0));
Assert.assertEquals("SELECT INTVAL1 FROM QUERYSYNTAXENTITY WHERE (INTVAL1 = LOCATE('HI', 'ABCDEFGHIJKLMNOP'))", _sql2.remove(0));
} else if(platform.isDB2() || platform.isDerby()) {
Assert.assertEquals("SELECT INTVAL1 FROM QUERYSYNTAXENTITY WHERE (INTVAL1 = LOCATE('HI', 'ABCDEFGHIJKLMNOP'))", _sql2.remove(0));
} else if(platform.isOracle()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019 IBM Corporation. All rights reserved.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023 IBM Corporation. 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
Expand Down Expand Up @@ -156,7 +156,7 @@ private static boolean createCursorStoredProcedure(EntityManagerFactory emf) {
if(platform.isOracle()) {
proc.addOutputArgument("out_cursor_one", "SYS_REFCURSOR");
proc.addStatement("OPEN out_cursor_one FOR SELECT ITEM_STRING1 FROM STORED_PROCEDURE_ENTITY WHERE ITEM_INTEGER1 = in_param_one");
} else if (platform.isDB2()) {
} else if (platform.isDB2() && !platform.isDB2Z()) {
proc.addOutputArgument("out_cursor_one", "CURSOR");
proc.addStatement("SET out_cursor_one = CURSOR FOR SELECT ITEM_STRING1 FROM STORED_PROCEDURE_ENTITY WHERE ITEM_INTEGER1 = in_param_one; OPEN out_cursor_one");
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018 IBM and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023 IBM 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
Expand Down Expand Up @@ -38,7 +38,9 @@ public class TestVersioning {
@Emf(createTables = DDLGen.DROP_CREATE, classes = { TemporalVersionedEntity.class, TemporalVersionedEntity2.class,
IntegerVersionedEntity.class},
properties = { @Property(name="eclipselink.logging.level", value="FINE"),
@Property(name="eclipselink.logging.parameters", value="true")})
@Property(name="eclipselink.logging.parameters", value="true"),
@Property(name = "eclipselink.target-database-properties",
value = "UseNationalCharacterVaryingTypeForString=true")})
private EntityManagerFactory emf;

private final static String qStr1 = "UPDATE TemporalVersionedEntity " +
Expand Down