pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Joseph Krogh <andreas@visena.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Fw: mapping java objects with postgresql types
Date: Fri, 23 Jan 2015 15:52:23 +0100 (CET)
Message-ID: <VisenaEmail.b2.b8c2a9e5722fd824.14b174100f3@tc7-visena> (raw)
In-Reply-To: <957727519.268446.1422023812302.JavaMail.yahoo@mail.yahoo.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

På fredag 23. januar 2015 kl. 15:36:52, skrev Oussema Benjemaa <
ousema2003@yahoo.fr <mailto:ousema2003@yahoo.fr>>:   i downloaded this JAR 
pgjdbc-ng-0.3-complete.jar ... i'm asking if there is exemple for mapping java 
objects to postgresql ... with this api   You should use 0.4: 
https://github.com/impossibl/pgjdbc-ng/releases   Simple example of returning 
an array of project name-id pairs for all parent-projects: CREATE TYPE 
BigIntVarCharAS (f1 bigint, f2 varchar); SELECT ARRAY(WITH RECURSIVE t AS (
SELECT 1 AS level, p.entity_id, p.id, p.parent_id, p.name FROM onp_crm_project p
WHEREp.entity_id = project.entity_id UNION ALL  SELECT t.level + 1, c.entity_id,
c.id, c.parent_id, c.name FROM onp_crm_project c JOIN t ON c.id = t.parent_id) 
SELECT ROW (t.entity_id, t.name) :: BigIntVarChar FROM t ORDER BY level DESC) AS
project_parent_array I use a class like this: import java.sql.{SQLOutput, 
SQLInput, SQLData} class BigIntVarcharJdbcData extends SQLData { var id: Long = 
0 var name: String = null  var sqlType: String = null  override def 
getSQLTypeName:String = { sqlType } override def writeSQL(stream: SQLOutput): 
Unit = { stream.writeLong(id) stream.writeNString(name) } override def 
readSQL(stream:SQLInput, typeName: String): Unit = { sqlType = typeName id = 
stream.readLong()name = stream.readString() } } val typeMap = { val h = new 
HashMap[String, Class[_]]() h.put("bigintvarchar", classOf[BigIntVarcharJdbcData
])Collections.unmodifiableMap[String, Class[_]](h) } rs.getObject(
"project_parent_array", RowMapperHelper.typeMap).asInstanceOf[Array[
BigIntVarcharJdbcData]]   -- Andreas Joseph Krogh CTO / Partner - Visena AS 
Mobile: +47 909 56 963 andreas@visena.com <mailto:andreas@visena.com> 
www.visena.com <https://www.visena.com;  <https://www.visena.com;  

view thread (8+ messages)  latest in thread

Message-ID: <VisenaEmail.b2.b8c2a9e5722fd824.14b174100f3@tc7-visena>
Permalink:  ../VisenaEmail.b2.b8c2a9e5722fd824.14b174100f3@tc7-visena/
Also on:    postgresql.org/message-id/VisenaEmail.b2.b8c2a9e5722fd824.14b174100f3@tc7-visena

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: andreas@visena.com
  Subject: Re: Fw: mapping java objects with postgresql types
  In-Reply-To: <VisenaEmail.b2.b8c2a9e5722fd824.14b174100f3@tc7-visena>
  References: <957727519.268446.1422023812302.JavaMail.yahoo@mail.yahoo.com> <VisenaEmail.b2.b8c2a9e5722fd824.14b174100f3@tc7-visena>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox