|
13 | 13 | import java.util.HashMap; |
14 | 14 | import java.util.Map; |
15 | 15 |
|
| 16 | +import oracle.nosql.driver.UnsupportedQueryVersionException; |
16 | 17 | import oracle.nosql.driver.ops.PreparedStatement; |
17 | 18 | import oracle.nosql.driver.ops.PrepareRequest; |
18 | 19 | import oracle.nosql.driver.ops.PrepareResult; |
|
29 | 30 | */ |
30 | 31 | public class PrepareRequestSerializer extends BinaryProtocol |
31 | 32 | implements Serializer { |
| 33 | + @Override |
| 34 | + public void serialize(Request request, |
| 35 | + short serialVersion, |
| 36 | + ByteOutputStream out) |
| 37 | + throws IOException { |
| 38 | + throw new IllegalArgumentException("Missing query version " + |
| 39 | + "in prepare request serializer"); |
| 40 | + } |
32 | 41 |
|
33 | 42 | @Override |
34 | 43 | public void serialize(Request request, |
35 | 44 | short serialVersion, |
| 45 | + short queryVersion, |
36 | 46 | ByteOutputStream out) |
37 | 47 | throws IOException { |
38 | 48 |
|
| 49 | + /* QUERY_V4 and above not supported by V3 protocol */ |
| 50 | + if (queryVersion >= QueryDriver.QUERY_V4) { |
| 51 | + throw new UnsupportedQueryVersionException( |
| 52 | + "Query version " + queryVersion + |
| 53 | + " not supported by V3 protocol"); |
| 54 | + } |
| 55 | + |
39 | 56 | PrepareRequest prepRq = (PrepareRequest) request; |
40 | 57 |
|
41 | 58 | writeOpCode(out, OpCode.PREPARE); |
42 | 59 | serializeRequest(prepRq, out); |
43 | 60 | writeString(out, prepRq.getStatement()); |
44 | | - out.writeShort(QueryDriver.QUERY_VERSION); |
| 61 | + out.writeShort(queryVersion); |
45 | 62 | out.writeBoolean(prepRq.getQueryPlan()); |
46 | 63 | } |
47 | 64 |
|
48 | 65 | @Override |
49 | | - public PrepareResult deserialize(Request request, |
50 | | - ByteInputStream in, |
51 | | - short serialVersion) |
52 | | - throws IOException { |
| 66 | + public PrepareResult deserialize( |
| 67 | + Request request, |
| 68 | + ByteInputStream in, |
| 69 | + short serialVersion) throws IOException { |
| 70 | + throw new IllegalArgumentException("Missing query version " + |
| 71 | + "in prepare request deserializer"); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public PrepareResult deserialize( |
| 76 | + Request request, |
| 77 | + ByteInputStream in, |
| 78 | + short serialVersion, |
| 79 | + short queryVersion) throws IOException { |
| 80 | + |
| 81 | + /* QUERY_V4 and above not supported by V3 protocol */ |
| 82 | + if (queryVersion >= QueryDriver.QUERY_V4) { |
| 83 | + throw new UnsupportedQueryVersionException( |
| 84 | + "Query version " + queryVersion + |
| 85 | + " not supported by V3 protocol"); |
| 86 | + } |
53 | 87 |
|
54 | 88 | PrepareRequest prepRq = (PrepareRequest) request; |
55 | 89 | PrepareResult result = new PrepareResult(); |
|
0 commit comments