Search code examples
javapostgresqlpljava

Missing type mapping byte[] to bytea - plJava


i want to execute a plJava function like:

@Function
public static byte[] enrypt_rsa(String message, byte[] public_key)
{...}

But if i try to create a .jar file with maven (mvn clean package) i get the following Error message:

'No known mapping to an SQL type'

But the plJava wiki says it would map the Java type byte[] to the postgresql type bytea (See: https://github.com/tada/pljava/wiki/Default-type-mapping).

Does anyone know how i can fix this issue or force the mapping i need? (Or do you have another idea how to create rsa keys and de/encrypt messages with postgresql functions?)


Solution

  • The plJava developer showed me a workaround and i like to share the easy solution in case anyone else will find this post. Normally this shouldn't be necessary but in my case it is...

    We can define the type ourself so the code looks like

    @Function(type = "bytea")
    public static byte[] enrypt_rsa(String message,@SQLType("bytea") byte[] public_key)
    {...}
    

    Now there aren't any maven errors -> problem solved :)