[#1326] Error when deserialising BLOBs from Oracle UDTs
This commit is contained in:
parent
f1add09448
commit
711c7d011d
@ -43,6 +43,7 @@ import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.jooq.impl.Factory.table;
|
||||
import static org.jooq.impl.Factory.val;
|
||||
import static org.jooq.tools.reflect.Reflect.on;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.Arrays;
|
||||
@ -837,13 +838,15 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
UDTRecord<?> a1 = authors.get(0).getValue(TAuthor_ADDRESS());
|
||||
UDTRecord<?> a2 = authors.get(1).getValue(TAuthor_ADDRESS());
|
||||
|
||||
Object street1 = a1.getClass().getMethod("getStreet").invoke(a1);
|
||||
assertEquals("77", street1.getClass().getMethod("getNo").invoke(street1));
|
||||
assertEquals("Parliament Hill", street1.getClass().getMethod("getStreet").invoke(street1));
|
||||
assertEquals("NW31A9", a1.getClass().getMethod("getZip").invoke(a1));
|
||||
assertEquals("Hampstead", a1.getClass().getMethod("getCity").invoke(a1));
|
||||
assertEquals("England", "" + a1.getClass().getMethod("getCountry").invoke(a1));
|
||||
assertEquals(null, a1.getClass().getMethod("getCode").invoke(a1));
|
||||
Object street1 = on(a1).call("getStreet").get();
|
||||
assertEquals("77", on(street1).call("getNo").get());
|
||||
assertEquals("Parliament Hill", on(street1).call("getStreet").get());
|
||||
assertTrue(Arrays.equals(new byte[] { 0x70, 0x70 }, on(street1).call("getF_1323").<byte[]>get()));
|
||||
assertEquals("NW31A9", on(a1).call("getZip").get());
|
||||
assertEquals("Hampstead", on(a1).call("getCity").get());
|
||||
assertEquals("England", "" + on(a1).call("getCountry").get());
|
||||
assertEquals(null, on(a1).call("getCode").get());
|
||||
assertTrue(Arrays.equals(new byte[] { 0x71, 0x71 }, on(a1).call("getF_1323").<byte[]>get()));
|
||||
|
||||
if (TArrays_NUMBER_R() != null) {
|
||||
assertEquals(Arrays.asList(1, 2, 3), invoke(invoke(street1, "getFloors"), "getList"));
|
||||
@ -852,13 +855,15 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658, T725
|
||||
assertEquals(Arrays.asList(1, 2, 3), Arrays.asList((Object[]) invoke(street1, "getFloors")));
|
||||
}
|
||||
|
||||
Object street2 = a2.getClass().getMethod("getStreet").invoke(a2);
|
||||
assertEquals("43.003", street1.getClass().getMethod("getNo").invoke(street2));
|
||||
assertEquals("Caixa Postal", street1.getClass().getMethod("getStreet").invoke(street2));
|
||||
assertEquals(null, a2.getClass().getMethod("getZip").invoke(a2));
|
||||
assertEquals("Rio de Janeiro", a2.getClass().getMethod("getCity").invoke(a2));
|
||||
assertEquals("Brazil", "" + a1.getClass().getMethod("getCountry").invoke(a2));
|
||||
assertEquals(2, a1.getClass().getMethod("getCode").invoke(a2));
|
||||
Object street2 = on(a2).call("getStreet").get();
|
||||
assertEquals("43.003", on(street2).call("getNo").get());
|
||||
assertEquals("Caixa Postal", on(street2).call("getStreet").get());
|
||||
assertEquals(null, on(street2).call("getF_1323").<byte[]>get());
|
||||
assertEquals(null, on(a2).call("getZip").get());
|
||||
assertEquals("Rio de Janeiro", on(a2).call("getCity").get());
|
||||
assertEquals("Brazil", "" + on(a2).call("getCountry").get());
|
||||
assertEquals(2, on(a2).call("getCode").get());
|
||||
assertEquals(null, on(a2).call("getF_1323").<byte[]>get());
|
||||
|
||||
if (TArrays_NUMBER_R() != null) {
|
||||
assertEquals(null, invoke(street2, "getFloors"));
|
||||
|
||||
@ -225,7 +225,9 @@ CREATE TYPE u_date_table AS TABLE OF DATE/
|
||||
CREATE TYPE u_street_type AS OBJECT (
|
||||
street VARCHAR2(100),
|
||||
no VARCHAR2(30),
|
||||
floors u_number_array
|
||||
floors u_number_array,
|
||||
f_1323 blob,
|
||||
f_1326 clob
|
||||
)
|
||||
/
|
||||
|
||||
@ -235,7 +237,9 @@ CREATE TYPE u_address_type AS OBJECT (
|
||||
city VARCHAR2(50),
|
||||
country VARCHAR2(50),
|
||||
since DATE,
|
||||
code NUMBER(7)
|
||||
code NUMBER(7),
|
||||
f_1323 blob,
|
||||
f_1326 clob
|
||||
)
|
||||
/
|
||||
|
||||
@ -682,7 +686,9 @@ END p_enhance_address2;
|
||||
CREATE OR REPLACE PROCEDURE p_enhance_address3 (address IN OUT u_address_type)
|
||||
IS
|
||||
BEGIN
|
||||
address.street := u_street_type('Zwinglistrasse', '17', u_number_array(2));
|
||||
address.street.street := 'Zwinglistrasse';
|
||||
address.street.no := '17';
|
||||
address.street.floors := u_number_array(2);
|
||||
END p_enhance_address3;
|
||||
/
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ package org.jooq.test.oracle.generatedclasses.test.tables.pojos;
|
||||
@javax.persistence.Table(name = "V_AUTHOR", schema = "TEST")
|
||||
public class VAuthor implements java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 312765320;
|
||||
private static final long serialVersionUID = 1871617822;
|
||||
|
||||
|
||||
@javax.validation.constraints.NotNull
|
||||
@ -71,7 +71,7 @@ public class VAuthor implements java.io.Serializable {
|
||||
this.yearOfBirth = yearOfBirth;
|
||||
}
|
||||
|
||||
@javax.persistence.Column(name = "ADDRESS", length = 448)
|
||||
@javax.persistence.Column(name = "ADDRESS", length = 40)
|
||||
public org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ package org.jooq.test.oracle.generatedclasses.test.tables.records;
|
||||
@javax.persistence.Table(name = "V_AUTHOR", schema = "TEST")
|
||||
public class VAuthorRecord extends org.jooq.impl.TableRecordImpl<org.jooq.test.oracle.generatedclasses.test.tables.records.VAuthorRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1073715627;
|
||||
private static final long serialVersionUID = 1750224359;
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
@ -97,7 +97,7 @@ public class VAuthorRecord extends org.jooq.impl.TableRecordImpl<org.jooq.test.o
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
@javax.persistence.Column(name = "ADDRESS", length = 448)
|
||||
@javax.persistence.Column(name = "ADDRESS", length = 40)
|
||||
public org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord getAddress() {
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.tables.VAuthor.V_AUTHOR.ADDRESS);
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle.generatedclasses.test.udt;
|
||||
*/
|
||||
public class UAddressType extends org.jooq.impl.UDTImpl<org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord> {
|
||||
|
||||
private static final long serialVersionUID = 781413964;
|
||||
private static final long serialVersionUID = -849475538;
|
||||
|
||||
/**
|
||||
* The singleton instance of TEST.U_ADDRESS_TYPE
|
||||
@ -58,6 +58,16 @@ public class UAddressType extends org.jooq.impl.UDTImpl<org.jooq.test.oracle.gen
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord, java.lang.Integer> CODE = createField("CODE", org.jooq.impl.SQLDataType.INTEGER, U_ADDRESS_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord, byte[]> F_1323 = createField("F_1323", org.jooq.impl.SQLDataType.BLOB, U_ADDRESS_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord, java.lang.String> F_1326 = createField("F_1326", org.jooq.impl.SQLDataType.CLOB, U_ADDRESS_TYPE);
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle.generatedclasses.test.udt;
|
||||
*/
|
||||
public class UStreetType extends org.jooq.impl.UDTImpl<org.jooq.test.oracle.generatedclasses.test.udt.records.UStreetTypeRecord> {
|
||||
|
||||
private static final long serialVersionUID = -1903797174;
|
||||
private static final long serialVersionUID = -948161688;
|
||||
|
||||
/**
|
||||
* The singleton instance of TEST.U_STREET_TYPE
|
||||
@ -43,6 +43,16 @@ public class UStreetType extends org.jooq.impl.UDTImpl<org.jooq.test.oracle.gene
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle.generatedclasses.test.udt.records.UStreetTypeRecord, org.jooq.test.oracle.generatedclasses.test.udt.records.UNumberArrayRecord> FLOORS = createField("FLOORS", org.jooq.impl.SQLDataType.INTEGER.asArrayDataType(org.jooq.test.oracle.generatedclasses.test.udt.records.UNumberArrayRecord.class), U_STREET_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle.generatedclasses.test.udt.records.UStreetTypeRecord, byte[]> F_1323 = createField("F_1323", org.jooq.impl.SQLDataType.BLOB, U_STREET_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle.generatedclasses.test.udt.records.UStreetTypeRecord, java.lang.String> F_1326 = createField("F_1326", org.jooq.impl.SQLDataType.CLOB, U_STREET_TYPE);
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle.generatedclasses.test.udt.records;
|
||||
*/
|
||||
public class UAddressTypeRecord extends org.jooq.impl.UDTRecordImpl<org.jooq.test.oracle.generatedclasses.test.udt.records.UAddressTypeRecord> {
|
||||
|
||||
private static final long serialVersionUID = 159216626;
|
||||
private static final long serialVersionUID = -784892408;
|
||||
|
||||
|
||||
/**
|
||||
@ -95,6 +95,34 @@ public class UAddressTypeRecord extends org.jooq.impl.UDTRecordImpl<org.jooq.tes
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.udt.UAddressType.CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1323(byte[] value) {
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.udt.UAddressType.F_1323, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public byte[] getF_1323() {
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.udt.UAddressType.F_1323);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1326(java.lang.String value) {
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.udt.UAddressType.F_1326, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public java.lang.String getF_1326() {
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.udt.UAddressType.F_1326);
|
||||
}
|
||||
|
||||
public UAddressTypeRecord() {
|
||||
super(org.jooq.test.oracle.generatedclasses.test.udt.UAddressType.U_ADDRESS_TYPE);
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle.generatedclasses.test.udt.records;
|
||||
*/
|
||||
public class UStreetTypeRecord extends org.jooq.impl.UDTRecordImpl<org.jooq.test.oracle.generatedclasses.test.udt.records.UStreetTypeRecord> {
|
||||
|
||||
private static final long serialVersionUID = -838066655;
|
||||
private static final long serialVersionUID = -615019899;
|
||||
|
||||
|
||||
/**
|
||||
@ -53,6 +53,34 @@ public class UStreetTypeRecord extends org.jooq.impl.UDTRecordImpl<org.jooq.test
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.udt.UStreetType.FLOORS);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1323(byte[] value) {
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.udt.UStreetType.F_1323, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public byte[] getF_1323() {
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.udt.UStreetType.F_1323);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1326(java.lang.String value) {
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.udt.UStreetType.F_1326, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public java.lang.String getF_1326() {
|
||||
return getValue(org.jooq.test.oracle.generatedclasses.test.udt.UStreetType.F_1326);
|
||||
}
|
||||
|
||||
public UStreetTypeRecord() {
|
||||
super(org.jooq.test.oracle.generatedclasses.test.udt.UStreetType.U_STREET_TYPE);
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ INSERT INTO t_658_32 VALUES (2, 2)/
|
||||
INSERT INTO t_658_32 VALUES (3, 3)/
|
||||
INSERT INTO t_658_ref VALUES ('A', 1, 1, 'B', 2, 2)/
|
||||
|
||||
INSERT INTO t_author VALUES (s_author_id.nextval, 'George', 'Orwell', TO_DATE('1903-06-25', 'YYYY-MM-DD'), 1903, u_address_type(u_street_type('Parliament Hill', '77', u_number_array(1, 2, 3)), 'NW31A9', 'Hampstead', 'England', TO_DATE('1980-01-01', 'YYYY-MM-DD'), null))/
|
||||
INSERT INTO t_author VALUES (s_author_id.nextval, 'Paulo', 'Coelho', TO_DATE('1947-08-24', 'YYYY-MM-DD'), 1947, u_address_type(u_street_type('Caixa Postal', '43.003', null), null, 'Rio de Janeiro', 'Brazil', TO_DATE('1940-01-01', 'YYYY-MM-DD'), 2))/
|
||||
INSERT INTO t_author VALUES (s_author_id.nextval, 'George', 'Orwell', TO_DATE('1903-06-25', 'YYYY-MM-DD'), 1903, u_address_type(u_street_type('Parliament Hill', '77', u_number_array(1, 2, 3), hextoraw('7070'), 'aabb'), 'NW31A9', 'Hampstead', 'England', TO_DATE('1980-01-01', 'YYYY-MM-DD'), null, hextoraw('7171'), 'xxyy'))/
|
||||
INSERT INTO t_author VALUES (s_author_id.nextval, 'Paulo', 'Coelho', TO_DATE('1947-08-24', 'YYYY-MM-DD'), 1947, u_address_type(u_street_type('Caixa Postal', '43.003', null, null, null), null, 'Rio de Janeiro', 'Brazil', TO_DATE('1940-01-01', 'YYYY-MM-DD'), 2, null, null))/
|
||||
|
||||
INSERT INTO t_book VALUES (1, 1, null, null, '1984', 1948, 1, 'To know and not to know, to be conscious of complete truthfulness while telling carefully constructed lies, to hold simultaneously two opinions which cancelled out, knowing them to be contradictory and believing in both of them, to use logic against logic, to repudiate morality while laying claim to it, to believe that democracy was impossible and that the Party was the guardian of democracy, to forget, whatever it was necessary to forget, then to draw it back into memory again at the moment when it was needed, and then promptly to forget it again, and above all, to apply the same process to the process itself -- that was the ultimate subtlety; consciously to induce unconsciousness, and then, once again, to become unconscious of the act of hypnosis you had just performed. Even to understand the word ''doublethink'' involved the use of doublethink..', null)/
|
||||
INSERT INTO t_book VALUES (2, 1, null, null, 'Animal Farm', 1945, 1, null, null)/
|
||||
|
||||
@ -10,7 +10,7 @@ package org.jooq.test.oracle3.generatedclasses.tables.pojos;
|
||||
@javax.persistence.Table(name = "V_AUTHOR", schema = "TEST")
|
||||
public class V_AUTHOR_POJO extends java.lang.ThreadDeath implements java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1369668504;
|
||||
private static final long serialVersionUID = -1900821802;
|
||||
|
||||
private java.lang.Integer ID;
|
||||
private java.lang.String FIRST_NAME;
|
||||
@ -64,7 +64,7 @@ public class V_AUTHOR_POJO extends java.lang.ThreadDeath implements java.lang.Cl
|
||||
this.YEAR_OF_BIRTH = YEAR_OF_BIRTH;
|
||||
}
|
||||
|
||||
@javax.persistence.Column(name = "ADDRESS", length = 448)
|
||||
@javax.persistence.Column(name = "ADDRESS", length = 40)
|
||||
public org.jooq.test.oracle3.generatedclasses.udt.records.U_ADDRESS_TYPE getADDRESS() {
|
||||
return this.ADDRESS;
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle3.generatedclasses.udt;
|
||||
*/
|
||||
public class U_ADDRESS_TYPE extends org.jooq.impl.UDTImpl<org.jooq.test.oracle3.generatedclasses.udt.records.U_ADDRESS_TYPE> implements java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -1438599870;
|
||||
private static final long serialVersionUID = -805498140;
|
||||
|
||||
/**
|
||||
* The singleton instance of TEST.U_ADDRESS_TYPE
|
||||
@ -58,6 +58,16 @@ public class U_ADDRESS_TYPE extends org.jooq.impl.UDTImpl<org.jooq.test.oracle3.
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle3.generatedclasses.udt.records.U_ADDRESS_TYPE, java.lang.Integer> CODE = createField("CODE", org.jooq.impl.SQLDataType.INTEGER, U_ADDRESS_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle3.generatedclasses.udt.records.U_ADDRESS_TYPE, byte[]> F_1323 = createField("F_1323", org.jooq.impl.SQLDataType.BLOB, U_ADDRESS_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle3.generatedclasses.udt.records.U_ADDRESS_TYPE, java.lang.String> F_1326 = createField("F_1326", org.jooq.impl.SQLDataType.CLOB, U_ADDRESS_TYPE);
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle3.generatedclasses.udt;
|
||||
*/
|
||||
public class U_STREET_TYPE extends org.jooq.impl.UDTImpl<org.jooq.test.oracle3.generatedclasses.udt.records.U_STREET_TYPE> implements java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1786177499;
|
||||
private static final long serialVersionUID = -598064775;
|
||||
|
||||
/**
|
||||
* The singleton instance of TEST.U_STREET_TYPE
|
||||
@ -43,6 +43,16 @@ public class U_STREET_TYPE extends org.jooq.impl.UDTImpl<org.jooq.test.oracle3.g
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle3.generatedclasses.udt.records.U_STREET_TYPE, org.jooq.test.oracle3.generatedclasses.udt.records.U_NUMBER_ARRAY> FLOORS = createField("FLOORS", org.jooq.impl.SQLDataType.INTEGER.asArrayDataType(org.jooq.test.oracle3.generatedclasses.udt.records.U_NUMBER_ARRAY.class), U_STREET_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle3.generatedclasses.udt.records.U_STREET_TYPE, byte[]> F_1323 = createField("F_1323", org.jooq.impl.SQLDataType.BLOB, U_STREET_TYPE);
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public static final org.jooq.UDTField<org.jooq.test.oracle3.generatedclasses.udt.records.U_STREET_TYPE, java.lang.String> F_1326 = createField("F_1326", org.jooq.impl.SQLDataType.CLOB, U_STREET_TYPE);
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle3.generatedclasses.udt.records;
|
||||
*/
|
||||
public class U_ADDRESS_TYPE extends org.jooq.impl.UDTRecordImpl<org.jooq.test.oracle3.generatedclasses.udt.records.U_ADDRESS_TYPE> implements java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -1152928371;
|
||||
private static final long serialVersionUID = -1722726941;
|
||||
|
||||
|
||||
/**
|
||||
@ -95,6 +95,34 @@ public class U_ADDRESS_TYPE extends org.jooq.impl.UDTRecordImpl<org.jooq.test.or
|
||||
return getValue(org.jooq.test.oracle3.generatedclasses.udt.U_ADDRESS_TYPE.CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1323(byte[] value) {
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.udt.U_ADDRESS_TYPE.F_1323, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public byte[] getF_1323() {
|
||||
return getValue(org.jooq.test.oracle3.generatedclasses.udt.U_ADDRESS_TYPE.F_1323);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1326(java.lang.String value) {
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.udt.U_ADDRESS_TYPE.F_1326, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public java.lang.String getF_1326() {
|
||||
return getValue(org.jooq.test.oracle3.generatedclasses.udt.U_ADDRESS_TYPE.F_1326);
|
||||
}
|
||||
|
||||
public U_ADDRESS_TYPE() {
|
||||
super(org.jooq.test.oracle3.generatedclasses.udt.U_ADDRESS_TYPE.U_ADDRESS_TYPE);
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ package org.jooq.test.oracle3.generatedclasses.udt.records;
|
||||
*/
|
||||
public class U_STREET_TYPE extends org.jooq.impl.UDTRecordImpl<org.jooq.test.oracle3.generatedclasses.udt.records.U_STREET_TYPE> implements java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 718004150;
|
||||
private static final long serialVersionUID = 1993799262;
|
||||
|
||||
|
||||
/**
|
||||
@ -53,6 +53,34 @@ public class U_STREET_TYPE extends org.jooq.impl.UDTRecordImpl<org.jooq.test.ora
|
||||
return getValue(org.jooq.test.oracle3.generatedclasses.udt.U_STREET_TYPE.FLOORS);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1323(byte[] value) {
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.udt.U_STREET_TYPE.F_1323, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public byte[] getF_1323() {
|
||||
return getValue(org.jooq.test.oracle3.generatedclasses.udt.U_STREET_TYPE.F_1323);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public void setF_1326(java.lang.String value) {
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.udt.U_STREET_TYPE.F_1326, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* An uncommented item
|
||||
*/
|
||||
public java.lang.String getF_1326() {
|
||||
return getValue(org.jooq.test.oracle3.generatedclasses.udt.U_STREET_TYPE.F_1326);
|
||||
}
|
||||
|
||||
public U_STREET_TYPE() {
|
||||
super(org.jooq.test.oracle3.generatedclasses.udt.U_STREET_TYPE.U_STREET_TYPE);
|
||||
}
|
||||
|
||||
@ -35,8 +35,12 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Delete;
|
||||
@ -62,21 +66,82 @@ class DefaultExecuteContext extends AbstractConfiguration implements ExecuteCont
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -6653474082935089963L;
|
||||
private static final long serialVersionUID = -6653474082935089963L;
|
||||
|
||||
// Persistent attributes
|
||||
private final Query query;
|
||||
private final Routine<?> routine;
|
||||
private String sql;
|
||||
private final Query query;
|
||||
private final Routine<?> routine;
|
||||
private String sql;
|
||||
|
||||
private final Query[] batchQueries;
|
||||
private final String[] batchSQL;
|
||||
private final Query[] batchQueries;
|
||||
private final String[] batchSQL;
|
||||
|
||||
// Transient attributes
|
||||
private transient PreparedStatement statement;
|
||||
private transient ResultSet resultSet;
|
||||
private transient Record record;
|
||||
private transient Result<?> result;
|
||||
private transient PreparedStatement statement;
|
||||
private transient ResultSet resultSet;
|
||||
private transient Record record;
|
||||
private transient Result<?> result;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: Static utility methods for handling blob / clob lifecycle
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private static final ThreadLocal<List<Blob>> BLOBS = new ThreadLocal<List<Blob>>();
|
||||
private static final ThreadLocal<List<Clob>> CLOBS = new ThreadLocal<List<Clob>>();
|
||||
|
||||
/**
|
||||
* Clean up blobs and clobs.
|
||||
* <p>
|
||||
* [#1326] This is necessary in those dialects that have long-lived
|
||||
* temporary lob objects, which can cause memory leaks in certain contexts,
|
||||
* where the lobs' underlying session / connection is long-lived as well.
|
||||
* Specifically, Oracle and ojdbc have some trouble when streaming temporary
|
||||
* lobs to UDTs:
|
||||
* <ol>
|
||||
* <li>The lob cannot have a call-scoped life time with UDTs</li>
|
||||
* <li>Freeing the lob after binding will cause an ORA-22275</li>
|
||||
* <li>Not freeing the lob after execution will cause an
|
||||
* {@link OutOfMemoryError}</li>
|
||||
* </ol>
|
||||
*/
|
||||
static final void clean() {
|
||||
List<Blob> blobs = BLOBS.get();
|
||||
List<Clob> clobs = CLOBS.get();
|
||||
|
||||
if (blobs != null) {
|
||||
for (Blob blob : blobs) {
|
||||
Util.safeFree(blob);
|
||||
}
|
||||
|
||||
BLOBS.remove();
|
||||
}
|
||||
|
||||
if (clobs != null) {
|
||||
for (Clob clob : clobs) {
|
||||
Util.safeFree(clob);
|
||||
}
|
||||
|
||||
CLOBS.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a blob for later cleanup with {@link #clean()}
|
||||
*/
|
||||
static final void register(Blob blob) {
|
||||
BLOBS.get().add(blob);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a clob for later cleanup with {@link #clean()}
|
||||
*/
|
||||
static final void register(Clob clob) {
|
||||
CLOBS.get().add(clob);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: Constructors
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
DefaultExecuteContext(Configuration configuration) {
|
||||
this(configuration, null, null, null);
|
||||
@ -110,6 +175,10 @@ class DefaultExecuteContext extends AbstractConfiguration implements ExecuteCont
|
||||
else {
|
||||
this.batchSQL = new String[0];
|
||||
}
|
||||
|
||||
clean();
|
||||
BLOBS.set(new ArrayList<Blob>());
|
||||
CLOBS.set(new ArrayList<Clob>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -39,6 +39,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.impl.Factory.getNewFactory;
|
||||
import static org.jooq.tools.reflect.Reflect.on;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@ -116,6 +117,7 @@ public final class FieldTypeHelper {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getFromSQLInput(Configuration configuration, SQLInput stream, Field<T> field) throws SQLException {
|
||||
Class<? extends T> type = field.getType();
|
||||
DataType<T> dataType = field.getDataType();
|
||||
|
||||
if (type == Blob.class) {
|
||||
return (T) stream.readBlob();
|
||||
@ -134,7 +136,21 @@ public final class FieldTypeHelper {
|
||||
return (T) checkWasNull(stream, Byte.valueOf(stream.readByte()));
|
||||
}
|
||||
else if (type == byte[].class) {
|
||||
return (T) stream.readBytes();
|
||||
|
||||
// [#1327] Oracle cannot deserialise BLOBs as byte[] from SQLInput
|
||||
if (dataType.isLob()) {
|
||||
Blob blob = null;
|
||||
try {
|
||||
blob = stream.readBlob();
|
||||
return (T) (blob == null ? null : blob.getBytes(1, (int) blob.length()));
|
||||
}
|
||||
finally {
|
||||
Util.safeFree(blob);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return (T) stream.readBytes();
|
||||
}
|
||||
}
|
||||
else if (type == Clob.class) {
|
||||
return (T) stream.readClob();
|
||||
@ -216,10 +232,10 @@ public final class FieldTypeHelper {
|
||||
public static <T> void writeToSQLOutput(SQLOutput stream, Field<T> field, T value) throws SQLException {
|
||||
Class<? extends T> type = field.getType();
|
||||
|
||||
writeToSQLOutput(stream, type, value);
|
||||
writeToSQLOutput(stream, type, field.getDataType(), value);
|
||||
}
|
||||
|
||||
public static <T> void writeToSQLOutput(SQLOutput stream, Class<? extends T> type, T value) throws SQLException {
|
||||
private static <T> void writeToSQLOutput(SQLOutput stream, Class<? extends T> type, DataType<T> dataType, T value) throws SQLException {
|
||||
if (value == null) {
|
||||
stream.writeObject(null);
|
||||
}
|
||||
@ -239,7 +255,29 @@ public final class FieldTypeHelper {
|
||||
stream.writeByte((Byte) value);
|
||||
}
|
||||
else if (type == byte[].class) {
|
||||
stream.writeBytes((byte[]) value);
|
||||
|
||||
// [#1327] Oracle cannot serialise BLOBs as byte[] to SQLOutput
|
||||
// Use reflection to avoid dependency on OJDBC
|
||||
if (dataType.isLob()) {
|
||||
Blob blob = null;
|
||||
|
||||
try {
|
||||
blob = on("oracle.sql.BLOB").call("createTemporary",
|
||||
on(stream).call("getSTRUCT")
|
||||
.call("getJavaSqlConnection").get(),
|
||||
false,
|
||||
on("oracle.sql.BLOB").get("DURATION_SESSION")).get();
|
||||
|
||||
blob.setBytes(1, (byte[]) value);
|
||||
stream.writeBlob(blob);
|
||||
}
|
||||
finally {
|
||||
DefaultExecuteContext.register(blob);
|
||||
}
|
||||
}
|
||||
else {
|
||||
stream.writeBytes((byte[]) value);
|
||||
}
|
||||
}
|
||||
else if (type == Clob.class) {
|
||||
stream.writeClob((Clob) value);
|
||||
@ -263,7 +301,29 @@ public final class FieldTypeHelper {
|
||||
stream.writeShort((Short) value);
|
||||
}
|
||||
else if (type == String.class) {
|
||||
stream.writeString((String) value);
|
||||
|
||||
// [#1327] Oracle cannot serialise CLOBs as String to SQLOutput
|
||||
// Use reflection to avoid dependency on OJDBC
|
||||
if (dataType.isLob()) {
|
||||
Clob clob = null;
|
||||
|
||||
try {
|
||||
clob = on("oracle.sql.CLOB").call("createTemporary",
|
||||
on(stream).call("getSTRUCT")
|
||||
.call("getJavaSqlConnection").get(),
|
||||
false,
|
||||
on("oracle.sql.CLOB").get("DURATION_SESSION")).get();
|
||||
|
||||
clob.setString(1, (String) value);
|
||||
stream.writeClob(clob);
|
||||
}
|
||||
finally {
|
||||
DefaultExecuteContext.register(clob);
|
||||
}
|
||||
}
|
||||
else {
|
||||
stream.writeString((String) value);
|
||||
}
|
||||
}
|
||||
else if (type == Time.class) {
|
||||
stream.writeTime((Time) value);
|
||||
@ -301,6 +361,13 @@ public final class FieldTypeHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - 2.3.0 - Do not reuse this method
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> void writeToSQLOutput(SQLOutput stream, Class<? extends T> type, T value) throws SQLException {
|
||||
writeToSQLOutput(stream, type, null, value);
|
||||
}
|
||||
|
||||
static <T, U> U getFromResultSet(ExecuteContext ctx, Field<U> field, int index)
|
||||
throws SQLException {
|
||||
|
||||
@ -46,6 +46,8 @@ import static org.jooq.tools.StringUtils.leftPad;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -479,6 +481,9 @@ final class Util {
|
||||
safeClose(ctx.resultSet());
|
||||
safeClose(ctx.statement());
|
||||
listener.end(ctx);
|
||||
|
||||
// [#1326] Clean up any potentially remaining temporary lobs
|
||||
DefaultExecuteContext.clean();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -525,6 +530,30 @@ final class Util {
|
||||
safeClose(statement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely free a blob
|
||||
*/
|
||||
static final void safeFree(Blob blob) {
|
||||
if (blob != null) {
|
||||
try {
|
||||
blob.free();
|
||||
}
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely free a clob
|
||||
*/
|
||||
static final void safeFree(Clob clob) {
|
||||
if (clob != null) {
|
||||
try {
|
||||
clob.free();
|
||||
}
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract an underlying connection
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user