原文はこちら。
https://blogs.oracle.com/oraclespatial/better-support-for-timestamp-with-zone-in-the-latest-oracle-spatial-and-graph-property-graph-patch
Oracle Spatial and Graph Property Graph機能のパッチがリリースされました。これには、PGX 3.1と最新のData Access Layerが含まれています。1つの重要な修正は、タイムゾーン付きタイムスタンプのサポートが向上したことです。
以下は改善点を説明する簡単な例です。
cfg = GraphConfigBuilder.forPropertyGraphRdbms()
.setJdbcUrl( "jdbc:oracle:thin:@127.0.0.1:1521:orcl122" )
.setUsername( "pg" )
.setPassword( "<YOUR_PASSWORD>" )
.setName( "test_graph" )
.setMaxNumConnections( 2 )
.setLoadEdgeLabel( false )
.addVertexProperty( "ts" , PropertyType.TIMESTAMP_WITH_TIMEZONE, null )
.addVertexProperty( "name" , PropertyType.STRING, "default_name" )
.addEdgeProperty( "cost" , PropertyType.DOUBLE, "1000000" )
.build();
opg = OraclePropertyGraph.getInstance(cfg);
v=opg.addVertex(10000l);
v.setProperty( "ts" , new Date(1000l));
opg.commit()
v=opg.getVertex(10000l);
==>Vertex ID 10000 [vertex] {ts:dat: 1969 - 12 - 31 16 : 00 : 01.0 }
|
上記の
getVertex
は
java.util.Date
型のプロパティを返します(
java.sql.Timestamp
は
java.util.Date
のサブクラス)。では、このグラフをリモートのPGXエンドポイントに読み込みましょう。
analyst=pgxSession.createAnalyst();
pgxGraph = pgxSession.readGraphWithProperties(opg.getConfig(), true );
|
OSG PGの旧バージョンでは、以下の例外が発生する場合があります。
"java.lang.UnsupportedOperationException: loading type time_with_timezone through DAL not yet supported"
|
このパッチを適用すると、もWith this new patch, the above will go through without a problem. To sanity check, run a simple PGQL query and print the type of the timestamp property ts.
pgxResultSet = pgxGraph.queryPgql( "SELECT n.ts MATCH (n)" )
elem=pgxResultSet.getResults()
e1=elem.iterator().next()
twz=e1.getTimestampWithTimezone( 0 )
==> 1969 - 12 -31T16: 00 :01Z
twz.getClass().getName()
==>java.time.OffsetDateTime
|
References:
Patch 28577866: MISSING LATEST PGX 3.1.X FUNCTIONS IN ORACLE 12.2 AND 18.1 (28577866)
https://support.oracle.com/rs?type=patch&id=28577866
0 件のコメント:
コメントを投稿