B4J Question jRDC2: ConvertObjectToBytes() cannot serialize UUId value from PostgreSQL

Diceman

Active Member
Licensed User
I am using B4j v6.51 and jRDC2 server with PostgreSQL. When I have an sql statement like "Select * from MyTable" and one of the columns is a UUID column the statement:

Dim data() As Byte = ser.ConvertObjectToBytes(res)​

will throw an exception:
B4X:
java.lang.RuntimeException: java.lang.RuntimeException: Cannot serialize object: de5cb930-168d-441f-9703-c71f57a4ee4c
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeType(B4XSerializator.java:268)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:224)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.WriteObject(B4XSerializator.java:104)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(B4XSerializator.java:62)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:628)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)

The method ser.ConvertObjectToBytes does not know how to serialize the UUID column. Is this something that can be fixed? For the time being I will rewrite the SQL statements to exclude any UUID column.

TIA
 

Diceman

Active Member
Licensed User
I will create a view of the table and use your concat() suggestion to pass back the UUID back to the user. I think it will be a good idea to always use views when returning data back to the user rather than putting the individual column names in a select statement in the config.properties text file. Config.Properties will simply have the "select * from viewx" and the intelligence and column list will be in the view definition which can also join tables together. This will make for a cleaner Config.Properties file. Thanks again for the solution.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…