Skip to content

WithItem is not Serializable #2144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mp911de opened this issue Jan 15, 2025 · 3 comments
Closed

WithItem is not Serializable #2144

mp911de opened this issue Jan 15, 2025 · 3 comments

Comments

@mp911de
Copy link

mp911de commented Jan 15, 2025

Seems that almost all model classes implement Serializable allowing to use Java Serialization for deep clones. However, WithItem doesn't implement Serializable leading to failures on serialization of a PlainSelect:

java.io.NotSerializableException: net.sf.jsqlparser.statement.select.WithItem
	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1187)
	at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:350)
	at java.base/java.util.ArrayList.writeObject(ArrayList.java:866)
	at java.base/jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1070)
	at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1516)
	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1438)
	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1181)
	at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1572)
	at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1529)
	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1438)
	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1181)
	at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:350)

I haven't checked any other new types whether these are serializable or not.

Reproducer:

String setQuery = "with sample_data(day, value) as (values ((0, 13), (1, 12), (2, 15), (3, 4), (4, 8), (5, 16))), test2 as (values (1,2,3)) \n"
		+ "select day, value from sample_data as a";

CCJSqlParser parser = CCJSqlParserUtil.newParser(setQuery);
PlainSelect select = (PlainSelect) parser.withAllowComplexParsing(true).Statement();
new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(select);
@manticore-projects
Copy link
Contributor

Thank you for reports.
This one is weird because Serializable should have been inherited from Statement. I just implemented this interface explicitly now and tested in successfully. Cheers

@mp911de
Copy link
Author

mp911de commented Jan 16, 2025

Thanks for the quick turnaround.

@manticore-projects
Copy link
Contributor

You are welcome. If you find any more models not serializable, please feel welcome to amend yourself and send a PR. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants