Skip to content

Commit

Permalink
Issue 1779: Add DB2zOS support for UNICODE Timestamps
Browse files Browse the repository at this point in the history
Signed-off-by: Will Dazey <dazeydev.3@gmail.com>
  • Loading branch information
dazey3 committed Feb 28, 2023
1 parent 23fe71f commit 633f401
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
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

0 comments on commit 633f401

Please sign in to comment.