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 BigIntVarChar AS (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 WHERE p.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