Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
¿Cómo convertir una lista de tuplas en un OID?

Tengo una instrucción SQL en la que me gustaría pasar una lista de tuplas customerIdSubCustomerPairs para poder obtener todas las filas que coincidan con la cláusula where de la tabla clients.

Este es el SQL para ello:

 @Language("PostgreSQL") private const val getExistingRowsSql = """ select customerId, subcustomer from customer where (uuid IN (:uuids) AND is_deleted = false) union select customerId, subcustomer from customer where (customerId, subcustomer) IN (:customerIdSubCustomerPairs) AND is_deleted = false """

Tengo una lista de customers a partir de la cual estoy creando una lista de listas para customerIdSubCustomerPairs . Se parece a esto:

 val existingCustomers = fetchRows( ctx, getExistingRowsSql, mapOf( "uuids" to customers.map { it["uuid"] }, "customerIdSubCustomerPairs" to customers.map { listOf(it["customerId"] as String, it["subCustomer"] as String) } ))

Y tengo una función donde convierto valores a tipos Oid :

 fun jdbcConvertValue(session: Session, v: Any?): Any? = when (v) { is Collection<*> -> { when (val type = v.firstOrNull()) { null -> null is String -> session.connection.underlying.createArrayOf("text", v.toTypedArray()) is Long -> session.connection.underlying.createArrayOf("bigint", v.toTypedArray()) is Int -> session.connection.underlying.createArrayOf("bigint", v.toTypedArray()) is UUID -> session.connection.underlying.createArrayOf("uuid", v.toTypedArray()) is List<*> -> v.map { jdbcConvertValue(session, it) }.toTypedArray() else -> throw Exception("You need to map your array type $type ${type.javaClass}") } } else -> v }

Sin embargo, cuando trato de obtener filas como esa, aparece un error:

 org.postgresql.util.PSQLException: Cannot cast an instance of [Ljava.lang.Object; to type Types.ARRAY

No estoy seguro de cómo pasar valores como tuplas a una declaración SQL. Los campos customerId y subcustomer son columnas de texto en la tabla DB.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda