Hello! There was a problem: you need to send a non-serializable implementation of the ScrollableResults hibernate interface using Netty over the network. I would love to use custom serialization, but Netty out of the box works with Serializable. Why do I need to send an object of this particular interface: I need to write an automatic generation of JavaFX tables according to the server's response. I tried solutions like:

public class ScrollAllResponce<T extends DB_Entity> extends AbstractEntityCommand<T> { private static final long serialVersionUID = -8151149290494368726L; private transient ScrollableResults results; public ScrollAllResponce(Class<T> entityClass, ScrollableResults results) { super(entityClass); this.results = results; } public ScrollableResults getResults() { return results; } private void writeObject(ObjectOutputStream stream) { try { stream.defaultWriteObject(); stream.writeObject(results); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void readObject(ObjectInputStream stream) { try { stream.defaultReadObject(); results = (ScrollableResults) stream.readObject(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } 

To which I get java.io.NotSerializableException: org.hibernate.internal.ScrollableResultsImpl in the writeObject method writeObject(ObjectOutputStream stream) I also tried to use in my wrapper not the interface, but the implementation, the result is the same. Apparently, the Hibernate implementation contains non-serializable objects. So how can you still send it? Perhaps I made a mistake at the design stage and incorrectly use ScrollableResults? Thanks in advance, I will be grateful for any help.

    1 answer 1

    Why do you need it? Transfer the data from ScrollableResults to the objects and send them, at least individually, at least in a sheet.

    from ScrollableResults you can get only the database data. Get them and send them. Forwarding a ScrollableResults object to anything.

    You also need to close it, as will the attempt to access ScrollableResults on a machine that did not open it?