[#1887] Remove all deprecated code
This commit is contained in:
parent
cbfc408c10
commit
f4e7c57732
@ -2783,21 +2783,21 @@ public class DefaultGenerator extends AbstractGenerator {
|
||||
ColumnDefinition referencingColumn = foreignKey.getKeyColumns().get(i);
|
||||
ColumnDefinition referencedColumn = foreignKey.getReferencedColumns().get(i);
|
||||
|
||||
out.print("\t\t\tsetValue(");
|
||||
out.print(getStrategy().getFullJavaIdentifier(referencingColumn));
|
||||
out.print(", value.getValue(");
|
||||
out.print(strategy.getFullJavaIdentifier(referencedColumn));
|
||||
|
||||
// Convert foreign key value, if there is a type mismatch
|
||||
DataTypeDefinition foreignType = referencingColumn.getType();
|
||||
DataTypeDefinition primaryType = referencedColumn.getType();
|
||||
|
||||
out.print("\t\t\tsetValue(");
|
||||
out.print(getStrategy().getFullJavaIdentifier(referencingColumn));
|
||||
out.print(", value.getValue");
|
||||
|
||||
// Convert foreign key value, if there is a type mismatch
|
||||
if (!match(foreignType, primaryType)) {
|
||||
out.print("As");
|
||||
out.print(", ");
|
||||
out.print(getSimpleJavaType(referencingColumn.getType()));
|
||||
out.print(".class");
|
||||
}
|
||||
|
||||
out.print("(");
|
||||
out.print(strategy.getFullJavaIdentifier(referencedColumn));
|
||||
out.println("));");
|
||||
}
|
||||
|
||||
@ -2834,19 +2834,19 @@ public class DefaultGenerator extends AbstractGenerator {
|
||||
for (int i = 0; i < foreignKey.getReferencedColumns().size(); i++) {
|
||||
out.print(connector);
|
||||
out.print(strategy.getFullJavaIdentifier(foreignKey.getReferencedColumns().get(i)));
|
||||
out.print(".equal(getValue");
|
||||
out.print(".equal(getValue(");
|
||||
out.print(strategy.getFullJavaIdentifier(foreignKey.getKeyColumns().get(i)));
|
||||
|
||||
// Convert foreign key value, if there is a type mismatch
|
||||
DataTypeDefinition foreignType = foreignKey.getKeyColumns().get(i).getType();
|
||||
DataTypeDefinition primaryType = foreignKey.getReferencedColumns().get(i).getType();
|
||||
|
||||
// Convert foreign key value, if there is a type mismatch
|
||||
if (!match(foreignType, primaryType)) {
|
||||
out.print("As");
|
||||
out.print(", ");
|
||||
out.print(getSimpleJavaType(foreignKey.getReferencedColumns().get(i).getType()));
|
||||
out.print(".class");
|
||||
}
|
||||
|
||||
out.print("(");
|
||||
out.print(strategy.getFullJavaIdentifier(foreignKey.getKeyColumns().get(i)));
|
||||
out.println(")))");
|
||||
|
||||
connector = "\t\t\t.and(";
|
||||
@ -2911,21 +2911,20 @@ public class DefaultGenerator extends AbstractGenerator {
|
||||
for (int i = 0; i < foreignKey.getReferencedColumns().size(); i++) {
|
||||
out.print(connector);
|
||||
out.print(strategy.getFullJavaIdentifier(foreignKey.getKeyColumns().get(i)));
|
||||
out.print(".equal(getValue");
|
||||
out.print(".equal(getValue(");
|
||||
out.print(strategy.getFullJavaIdentifier(uniqueKey.getKeyColumns().get(i)));
|
||||
|
||||
// Convert foreign key value, if there is a type mismatch
|
||||
DataTypeDefinition foreignType = foreignKey.getKeyColumns().get(i).getType();
|
||||
DataTypeDefinition primaryType = uniqueKey.getKeyColumns().get(i).getType();
|
||||
|
||||
// Convert foreign key value, if there is a type mismatch
|
||||
if (!match(foreignType, primaryType)) {
|
||||
out.print("As");
|
||||
out.print(", ");
|
||||
out.print(getSimpleJavaType(foreignKey.getKeyColumns().get(i).getType()));
|
||||
out.print(".class");
|
||||
}
|
||||
|
||||
out.print("(");
|
||||
out.print(strategy.getFullJavaIdentifier(uniqueKey.getKeyColumns().get(i)));
|
||||
out.println(")))");
|
||||
|
||||
connector = "\t\t\t.and(";
|
||||
}
|
||||
|
||||
|
||||
@ -638,73 +638,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
if (v) assertEquals(v4a, book4.getValue(TBook_REC_VERSION()));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
@Test
|
||||
public void testNonUpdatables() throws Exception {
|
||||
jOOQAbstractTest.reset = false;
|
||||
|
||||
// Insert three records first
|
||||
T785 record = create().newRecord(T785());
|
||||
record.setValue(T785_ID(), 1);
|
||||
assertEquals(1, record.storeUsing(T785_ID()));
|
||||
assertEquals(0, record.storeUsing(T785_ID()));
|
||||
|
||||
record.setValue(T785_ID(), 2);
|
||||
assertEquals(1, record.storeUsing(T785_ID()));
|
||||
record.setValue(T785_NAME(), "N");
|
||||
record.setValue(T785_VALUE(), "V");
|
||||
assertEquals(1, record.storeUsing(T785_ID()));
|
||||
|
||||
record = create().newRecord(T785());
|
||||
record.setValue(T785_ID(), 3);
|
||||
record.setValue(T785_NAME(), "N");
|
||||
assertEquals(1, record.storeUsing(T785_ID()));
|
||||
assertEquals(0, record.storeUsing(T785_ID()));
|
||||
|
||||
// Load data again
|
||||
record = create().newRecord(T785());
|
||||
record.setValue(T785_ID(), 2);
|
||||
record.refreshUsing(T785_ID());
|
||||
assertEquals("N", record.getValue(T785_NAME()));
|
||||
assertEquals("V", record.getValue(T785_VALUE()));
|
||||
|
||||
// When NAME is used as the key, multiple updates may occur
|
||||
record.setValue(T785_VALUE(), "Some value");
|
||||
assertEquals(2, record.storeUsing(T785_NAME()));
|
||||
assertEquals(2, create().fetch(T785(), T785_VALUE().equal("Some value")).size());
|
||||
|
||||
// Don't allow refreshing on multiple results
|
||||
try {
|
||||
record = create().newRecord(T785());
|
||||
record.setValue(T785_VALUE(), "Some value");
|
||||
record.refreshUsing(T785_VALUE());
|
||||
fail();
|
||||
}
|
||||
catch (InvalidResultException expected) {}
|
||||
|
||||
|
||||
// Don't allow refreshing on inexistent results
|
||||
try {
|
||||
record = create().newRecord(T785());
|
||||
record.setValue(T785_ID(), 4);
|
||||
record.refreshUsing(T785_ID());
|
||||
fail();
|
||||
}
|
||||
catch (InvalidResultException expected) {}
|
||||
|
||||
// Delete records again
|
||||
record = create().newRecord(T785());
|
||||
record.setValue(T785_ID(), 1);
|
||||
assertEquals(1, record.deleteUsing(T785_ID()));
|
||||
assertEquals(2, create().fetch(T785()).size());
|
||||
assertEquals(0, create().fetch(T785(), T785_ID().equal(1)).size());
|
||||
|
||||
record = create().newRecord(T785());
|
||||
record.setValue(T785_NAME(), "N");
|
||||
assertEquals(2, record.deleteUsing(T785_NAME()));
|
||||
assertEquals(0, create().fetch(T785()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreWithOptimisticLock() throws Exception {
|
||||
jOOQAbstractTest.reset = false;
|
||||
|
||||
@ -128,7 +128,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
/**
|
||||
* Extracted method for very similar tests with T_IDENTITY, T_IDENTITY_PK
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
private <R extends TableRecord<R>> void testInsertIdentity0(Table<R> table, TableField<R, Integer> id, TableField<R, Integer> val) throws Exception {
|
||||
|
||||
// Plain insert
|
||||
@ -196,22 +195,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
assertNull(r3.getValue(1, val));
|
||||
assertEquals(3, (int) r3.getValue(0, id));
|
||||
assertEquals(4, (int) r3.getValue(1, id));
|
||||
|
||||
// Record.storeUsing()
|
||||
R r4 = create().newRecord(table);
|
||||
r4.setValue(val, 20);
|
||||
assertEquals(1, r4.storeUsing(table.getIdentity().getField()));
|
||||
|
||||
if (getDialect() != POSTGRES &&
|
||||
getDialect() != DB2) {
|
||||
|
||||
assertEquals(new BigInteger("5"), create().lastID());
|
||||
assertEquals(new BigInteger("5"), create().lastID());
|
||||
}
|
||||
|
||||
// TODO [#1002] Fix this
|
||||
R r5 = create().fetchOne(table, id.equal(5));
|
||||
assertEquals(r5, r4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,7 +442,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
assertEquals("Hitchcock", author.getValue(TAuthor_LAST_NAME()));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
@Test
|
||||
public void testInsertReturning() throws Exception {
|
||||
if (TTriggers() == null) {
|
||||
@ -590,10 +572,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
assertNull(returned.getValue(TTriggers_ID_GENERATED()));
|
||||
assertNull(returned.getValue(TTriggers_COUNTER()));
|
||||
|
||||
returned.refreshUsing(TTriggers_ID());
|
||||
assertEquals( ID, (int) returned.getValue(TTriggers_ID_GENERATED()));
|
||||
assertEquals(2*ID, (int) returned.getValue(TTriggers_COUNTER()));
|
||||
|
||||
// store() and similar methods
|
||||
T triggered = create().newRecord(TTriggers());
|
||||
triggered.setValue(TTriggers_COUNTER(), 0);
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.cubrid.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.cubrid.generatedclasses.tables.records.XUnusedRecord> {
|
||||
|
||||
private static final long serialVersionUID = -1752803977;
|
||||
private static final long serialVersionUID = -854431573;
|
||||
|
||||
/**
|
||||
* The table column <code>DBA.x_unused.id</code>
|
||||
@ -50,8 +50,8 @@ public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.te
|
||||
public java.util.List<org.jooq.test.cubrid.generatedclasses.tables.records.XUnusedRecord> fetchXUnusedList() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.cubrid.generatedclasses.tables.XUnused.X_UNUSED)
|
||||
.where(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME_REF.equal(getValueAsString(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID)))
|
||||
.and(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID_REF.equal(getValueAsInteger(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME)))
|
||||
.where(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME_REF.equal(getValue(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID, String.class)))
|
||||
.and(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID_REF.equal(getValue(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME, Integer.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@ -125,8 +125,8 @@ public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.te
|
||||
public org.jooq.test.cubrid.generatedclasses.tables.records.XUnusedRecord fetchXUnused() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.cubrid.generatedclasses.tables.XUnused.X_UNUSED)
|
||||
.where(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID.equal(getValueAsInteger(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME_REF)))
|
||||
.and(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME.equal(getValueAsString(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID_REF)))
|
||||
.where(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID.equal(getValue(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME_REF, Integer.class)))
|
||||
.and(org.jooq.test.cubrid.generatedclasses.tables.XUnused.NAME.equal(getValue(org.jooq.test.cubrid.generatedclasses.tables.XUnused.ID_REF, String.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.db2.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.db2.generatedclasses.tables.records.XTestCase_64_69Record> {
|
||||
|
||||
private static final long serialVersionUID = 1317544343;
|
||||
private static final long serialVersionUID = 276189173;
|
||||
|
||||
/**
|
||||
* The table column <code>LUKAS.X_TEST_CASE_64_69.ID</code>
|
||||
@ -37,7 +37,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.db2.generatedclasses.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.ID)))
|
||||
.where(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.db2.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.db2.generatedclasses.tables.records.XTestCase_71Record> {
|
||||
|
||||
private static final long serialVersionUID = 529613240;
|
||||
private static final long serialVersionUID = -1081115366;
|
||||
|
||||
/**
|
||||
* The table column <code>LUKAS.X_TEST_CASE_71.ID</code>
|
||||
@ -64,7 +64,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.ID));
|
||||
setValue(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.db2.generatedclasses.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.ID.equal(getValueAsInteger(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.db2.generatedclasses.tables.XTestCase_64_69.ID.equal(getValue(org.jooq.test.db2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.firebird.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.firebird.generatedclasses.tables.records.XTestCase_64_69Record> implements org.jooq.test.firebird.generatedclasses.tables.interfaces.IXTestCase_64_69 {
|
||||
|
||||
private static final long serialVersionUID = -1957510094;
|
||||
private static final long serialVersionUID = 1991131320;
|
||||
|
||||
/**
|
||||
* The table column <code>X_TEST_CASE_64_69.ID</code>
|
||||
@ -39,7 +39,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.firebird.generatedclasses.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID)))
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.firebird.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.firebird.generatedclasses.tables.records.XTestCase_71Record> implements org.jooq.test.firebird.generatedclasses.tables.interfaces.IXTestCase_71 {
|
||||
|
||||
private static final long serialVersionUID = 1617435860;
|
||||
private static final long serialVersionUID = -1060983750;
|
||||
|
||||
/**
|
||||
* The table column <code>X_TEST_CASE_71.ID</code>
|
||||
@ -68,7 +68,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID));
|
||||
setValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.firebird.generatedclasses.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValueAsInteger(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.firebird.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_85Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.firebird.generatedclasses.tables.records.XTestCase_85Record> implements org.jooq.test.firebird.generatedclasses.tables.interfaces.IXTestCase_85 {
|
||||
|
||||
private static final long serialVersionUID = -677441195;
|
||||
private static final long serialVersionUID = -338310955;
|
||||
|
||||
/**
|
||||
* The table column <code>X_TEST_CASE_85.ID</code>
|
||||
@ -71,8 +71,8 @@ public class XTestCase_85Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.firebird.generatedclasses.tables.records.XUnusedRecord fetchXUnused() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED)
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME.equal(getValueAsString(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_ID)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID.equal(getValueAsInteger(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_NAME)))
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_ID, String.class)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_NAME, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.firebird.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.firebird.generatedclasses.tables.records.XUnusedRecord> implements org.jooq.test.firebird.generatedclasses.tables.interfaces.IXUnused {
|
||||
|
||||
private static final long serialVersionUID = 942475728;
|
||||
private static final long serialVersionUID = -1102619090;
|
||||
|
||||
/**
|
||||
* The table column <code>X_UNUSED.ID</code>
|
||||
@ -39,8 +39,8 @@ public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.te
|
||||
public java.util.List<org.jooq.test.firebird.generatedclasses.tables.records.XTestCase_85Record> fetchXTestCase_85List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85)
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_ID.equal(getValueAsInteger(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_NAME.equal(getValueAsString(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID)))
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_ID.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME, Integer.class)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XTestCase_85.X_TEST_CASE_85.X_UNUSED_NAME.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID, String.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.te
|
||||
public java.util.List<org.jooq.test.firebird.generatedclasses.tables.records.XUnusedRecord> fetchXUnusedList() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED)
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID_REF.equal(getValueAsInteger(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME_REF.equal(getValueAsString(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID)))
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID_REF.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME, Integer.class)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME_REF.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID, String.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@ -145,8 +145,8 @@ public class XUnusedRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.te
|
||||
public org.jooq.test.firebird.generatedclasses.tables.records.XUnusedRecord fetchXUnused() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED)
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME.equal(getValueAsString(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID_REF)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID.equal(getValueAsInteger(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME_REF)))
|
||||
.where(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID_REF, String.class)))
|
||||
.and(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.ID.equal(getValue(org.jooq.test.firebird.generatedclasses.tables.XUnused.X_UNUSED.NAME_REF, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.h2.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.h2.generatedclasses.tables.records.XTestCase_64_69Record> implements org.jooq.test.h2.generatedclasses.tables.interfaces.IXTestCase_64_69 {
|
||||
|
||||
private static final long serialVersionUID = -374768472;
|
||||
private static final long serialVersionUID = -2081892290;
|
||||
|
||||
/**
|
||||
* The table column <code>PUBLIC.X_TEST_CASE_64_69.ID</code>
|
||||
@ -39,7 +39,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.h2.generatedclasses.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.ID)))
|
||||
.where(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.h2.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.h2.generatedclasses.tables.records.XTestCase_71Record> implements org.jooq.test.h2.generatedclasses.tables.interfaces.IXTestCase_71 {
|
||||
|
||||
private static final long serialVersionUID = 1656252666;
|
||||
private static final long serialVersionUID = 1107662452;
|
||||
|
||||
/**
|
||||
* The table column <code>PUBLIC.X_TEST_CASE_71.ID</code>
|
||||
@ -68,7 +68,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.ID));
|
||||
setValue(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.h2.generatedclasses.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.ID.equal(getValueAsInteger(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.h2.generatedclasses.tables.XTestCase_64_69.ID.equal(getValue(org.jooq.test.h2.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.hsqldb.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.hsqldb.generatedclasses.tables.records.XTestCase_64_69Record> implements org.jooq.test.hsqldb.generatedclasses.tables.interfaces.IXTestCase_64_69 {
|
||||
|
||||
private static final long serialVersionUID = 1004455768;
|
||||
private static final long serialVersionUID = -899928748;
|
||||
|
||||
/**
|
||||
* The table column <code>PUBLIC.X_TEST_CASE_64_69.ID</code>
|
||||
@ -39,7 +39,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.hsqldb.generatedclasses.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID)))
|
||||
.where(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.hsqldb.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.hsqldb.generatedclasses.tables.records.XTestCase_71Record> implements org.jooq.test.hsqldb.generatedclasses.tables.interfaces.IXTestCase_71 {
|
||||
|
||||
private static final long serialVersionUID = 761205853;
|
||||
private static final long serialVersionUID = 689674263;
|
||||
|
||||
/**
|
||||
* The table column <code>PUBLIC.X_TEST_CASE_71.ID</code>
|
||||
@ -68,7 +68,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID));
|
||||
setValue(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.hsqldb.generatedclasses.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValueAsInteger(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValue(org.jooq.test.hsqldb.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -1323,11 +1323,6 @@ public abstract class jOOQAbstractTest<
|
||||
new CRUDTests(this).testStoreWithOptimisticLock();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonUpdatables() throws Exception {
|
||||
new CRUDTests(this).testNonUpdatables();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormat() throws Exception {
|
||||
new FormatTests(this).testFormat();
|
||||
|
||||
@ -11,7 +11,7 @@ package org.jooq.test.oracle.generatedclasses.test.tables.records;
|
||||
@javax.persistence.Table(name = "X_TEST_CASE_64_69", schema = "TEST")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.oracle.generatedclasses.test.tables.records.XTestCase_64_69Record> {
|
||||
|
||||
private static final long serialVersionUID = -1247423789;
|
||||
private static final long serialVersionUID = -1427665825;
|
||||
|
||||
/**
|
||||
* The table column <code>TEST.X_TEST_CASE_64_69.ID</code>
|
||||
@ -41,7 +41,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.oracle.generatedclasses.test.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID)))
|
||||
.where(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ package org.jooq.test.oracle.generatedclasses.test.tables.records;
|
||||
@javax.persistence.Table(name = "X_TEST_CASE_71", schema = "TEST")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.oracle.generatedclasses.test.tables.records.XTestCase_71Record> {
|
||||
|
||||
private static final long serialVersionUID = 1942916557;
|
||||
private static final long serialVersionUID = 1645093631;
|
||||
|
||||
/**
|
||||
* The table column <code>TEST.X_TEST_CASE_71.ID</code>
|
||||
@ -69,7 +69,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID));
|
||||
setValue(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.oracle.generatedclasses.test.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValueAsInteger(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValue(org.jooq.test.oracle.generatedclasses.test.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ package org.jooq.test.oracle3.generatedclasses.tables.records;
|
||||
@javax.persistence.Table(name = "X_TEST_CASE_64_69", schema = "TEST")
|
||||
public class X_TEST_CASE_64_69 extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.oracle3.generatedclasses.tables.records.X_TEST_CASE_64_69> implements java.lang.Cloneable, org.jooq.test.oracle3.generatedclasses.tables.interfaces.X_TEST_CASE_64_69_INTERFACE {
|
||||
|
||||
private static final long serialVersionUID = 632208317;
|
||||
private static final long serialVersionUID = 2088508871;
|
||||
|
||||
/**
|
||||
* The table column <code>TEST.X_TEST_CASE_64_69.ID</code>
|
||||
@ -43,7 +43,7 @@ public class X_TEST_CASE_64_69 extends org.jooq.impl.UpdatableRecordImpl<org.joo
|
||||
public java.util.List<org.jooq.test.oracle3.generatedclasses.tables.records.X_TEST_CASE_71> fetchX_TEST_CASE_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69.ID)))
|
||||
.where(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ package org.jooq.test.oracle3.generatedclasses.tables.records;
|
||||
@javax.persistence.Table(name = "X_TEST_CASE_71", schema = "TEST")
|
||||
public class X_TEST_CASE_71 extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.oracle3.generatedclasses.tables.records.X_TEST_CASE_71> implements java.lang.Cloneable, org.jooq.test.oracle3.generatedclasses.tables.interfaces.X_TEST_CASE_71_INTERFACE {
|
||||
|
||||
private static final long serialVersionUID = -1658239019;
|
||||
private static final long serialVersionUID = -672251853;
|
||||
|
||||
/**
|
||||
* The table column <code>TEST.X_TEST_CASE_71.ID</code>
|
||||
@ -73,7 +73,7 @@ public class X_TEST_CASE_71 extends org.jooq.impl.UpdatableRecordImpl<org.jooq.t
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69.ID));
|
||||
setValue(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ public class X_TEST_CASE_71 extends org.jooq.impl.UpdatableRecordImpl<org.jooq.t
|
||||
public org.jooq.test.oracle3.generatedclasses.tables.records.X_TEST_CASE_64_69 fetchX_TEST_CASE_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69.ID.equal(getValueAsInteger(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_64_69.X_TEST_CASE_64_69.ID.equal(getValue(org.jooq.test.oracle3.generatedclasses.tables.X_TEST_CASE_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ package org.jooq.test.postgres.generatedclasses.tables.records;
|
||||
@javax.persistence.Table(name = "x_test_case_64_69", schema = "public")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.postgres.generatedclasses.tables.records.XTestCase_64_69Record> {
|
||||
|
||||
private static final long serialVersionUID = -1436916508;
|
||||
private static final long serialVersionUID = 239850546;
|
||||
|
||||
/**
|
||||
* The table column <code>public.x_test_case_64_69.id</code>
|
||||
@ -41,7 +41,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.postgres.generatedclasses.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID)))
|
||||
.where(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ package org.jooq.test.postgres.generatedclasses.tables.records;
|
||||
@javax.persistence.Table(name = "x_test_case_71", schema = "public")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.postgres.generatedclasses.tables.records.XTestCase_71Record> {
|
||||
|
||||
private static final long serialVersionUID = -1473910236;
|
||||
private static final long serialVersionUID = -23880718;
|
||||
|
||||
/**
|
||||
* The table column <code>public.x_test_case_71.id</code>
|
||||
@ -69,7 +69,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID));
|
||||
setValue(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.postgres.generatedclasses.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValueAsInteger(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69.ID.equal(getValue(org.jooq.test.postgres.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.sqlite.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.sqlite.generatedclasses.tables.records.XTestCase_64_69Record> {
|
||||
|
||||
private static final long serialVersionUID = -790943707;
|
||||
private static final long serialVersionUID = -1237498625;
|
||||
|
||||
/**
|
||||
* The table column <code>x_test_case_64_69.ID</code>
|
||||
@ -37,7 +37,7 @@ public class XTestCase_64_69Record extends org.jooq.impl.UpdatableRecordImpl<org
|
||||
public java.util.List<org.jooq.test.sqlite.generatedclasses.tables.records.XTestCase_71Record> fetchXTestCase_71List() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.X_TEST_CASE_71)
|
||||
.where(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID.equal(getValueAsShort(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.ID)))
|
||||
.where(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID.equal(getValue(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.ID, Short.class)))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.sqlite.generatedclasses.tables.records;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.sqlite.generatedclasses.tables.records.XTestCase_71Record> {
|
||||
|
||||
private static final long serialVersionUID = 606484651;
|
||||
private static final long serialVersionUID = -792908643;
|
||||
|
||||
/**
|
||||
* The table column <code>x_test_case_71.ID</code>
|
||||
@ -64,7 +64,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
setValue(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, null);
|
||||
}
|
||||
else {
|
||||
setValue(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, value.getValueAsShort(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.ID));
|
||||
setValue(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, value.getValue(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.ID, Short.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class XTestCase_71Record extends org.jooq.impl.UpdatableRecordImpl<org.jo
|
||||
public org.jooq.test.sqlite.generatedclasses.tables.records.XTestCase_64_69Record fetchXTestCase_64_69() {
|
||||
return create()
|
||||
.selectFrom(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.X_TEST_CASE_64_69)
|
||||
.where(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.ID.equal(getValueAsInteger(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID)))
|
||||
.where(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_64_69.ID.equal(getValue(org.jooq.test.sqlite.generatedclasses.tables.XTestCase_71.TEST_CASE_64_69_ID, Integer.class)))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* A type that can dynamically implement another interface.
|
||||
* <p>
|
||||
* This interface is for JOOQ INTERNAL USE only. Do not reference directly
|
||||
*
|
||||
* @author Lukas Eder
|
||||
* @deprecated - 2.5.0 [#1639] - This part of the internal API will be removed
|
||||
* in the near future. Do not reuse.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Adapter {
|
||||
|
||||
/**
|
||||
* Adapt to an internal type assuming its functionality
|
||||
* <p>
|
||||
* This is for JOOQ INTERNAL USE only. If you need to access the internal
|
||||
* API, these are the known possible interfaces:
|
||||
* <ul>
|
||||
* <li> {@link QueryPartInternal}: The internal API for {@link QueryPart}</li>
|
||||
* </ul>
|
||||
* Be aware though, that the internal API may change even between minor
|
||||
* releases.
|
||||
*
|
||||
* @param <I> The internal type's generic type parameter.
|
||||
* @param internalType The internal type
|
||||
* @return This object wrapped by or cast to an internal type
|
||||
* @throws ClassCastException If this object cannot be wrapped by or cast to
|
||||
* the given internal type
|
||||
* @deprecated - 2.5.0 [#1639] - This part of the internal API will be
|
||||
* removed in the near future. Do not reuse.
|
||||
*/
|
||||
@Deprecated
|
||||
<I> I internalAPI(Class<I> internalType) throws ClassCastException;
|
||||
}
|
||||
@ -59,8 +59,7 @@ import javax.sql.DataSource;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Attachable extends Adapter, Serializable {
|
||||
public interface Attachable extends Serializable {
|
||||
|
||||
/**
|
||||
* Attach this object to a new {@link Configuration}
|
||||
|
||||
@ -43,12 +43,11 @@ package org.jooq;
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Package extends NamedQueryPart, org.jooq.SchemaProvider {
|
||||
public interface Package extends NamedQueryPart {
|
||||
|
||||
/**
|
||||
* Get the package schema
|
||||
*/
|
||||
@Override
|
||||
Schema getSchema();
|
||||
|
||||
/**
|
||||
|
||||
@ -118,19 +118,6 @@ public interface QueryPartInternal extends QueryPart {
|
||||
*/
|
||||
void bind(BindContext context) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Reproduce the SQL dialect this {@link QueryPart} was created with
|
||||
* <p>
|
||||
* This method is for JOOQ INTERNAL USE only. Do not reference directly
|
||||
*
|
||||
* @return The SQL dialect
|
||||
* @deprecated - 2.0.2 - The attached SQL dialect of a {@link QueryPart}
|
||||
* should no longer be referenced, as query parts become more
|
||||
* and more {@link Configuration} - independent
|
||||
*/
|
||||
@Deprecated
|
||||
SQLDialect getDialect();
|
||||
|
||||
/**
|
||||
* Check whether this {@link QueryPart} is able to declare fields in a
|
||||
* <code>SELECT</code> clause.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -83,12 +83,11 @@ import org.jooq.exception.DataAccessException;
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Routine<T> extends NamedQueryPart, org.jooq.SchemaProvider {
|
||||
public interface Routine<T> extends NamedQueryPart {
|
||||
|
||||
/**
|
||||
* Get the routine schema
|
||||
*/
|
||||
@Override
|
||||
Schema getSchema();
|
||||
|
||||
/**
|
||||
|
||||
@ -36,9 +36,7 @@
|
||||
|
||||
package org.jooq;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An entity representing a database schema
|
||||
@ -54,19 +52,6 @@ public interface Schema extends NamedQueryPart {
|
||||
@Override
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* The complete type mapping for this schema.
|
||||
* <p>
|
||||
* This method returns all generated types involved with this schema. The
|
||||
* result can be used in {@link ResultSet#getObject(int, Map)} and similar
|
||||
* methods.
|
||||
*
|
||||
* @see UDT#getTypeMapping() for a UDT-specific type mapping
|
||||
* @deprecated - 2.3.0 - Do not reuse this method
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String, Class<?>> getTypeMapping();
|
||||
|
||||
/**
|
||||
* List all tables contained in this schema
|
||||
*/
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* An object providing a {@link Schema}. This becomes particularly interesting,
|
||||
* when the schema is mapped.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
* @since 1.5.2
|
||||
* @deprecated - 2.5.0 [#1580] - The <code>org.jooq.SchemaProvider</code> marker
|
||||
* interface has not proven to be useful to the public API so far.
|
||||
* There is no real need to abstract its implementations with a
|
||||
* single interface
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SchemaProvider {
|
||||
|
||||
/**
|
||||
* @return The contained schema
|
||||
*/
|
||||
Schema getSchema();
|
||||
|
||||
}
|
||||
@ -67,7 +67,6 @@ public interface Table<R extends Record> extends org.jooq.Type<R>, AliasProvider
|
||||
/**
|
||||
* Get the table schema
|
||||
*/
|
||||
@Override
|
||||
Schema getSchema();
|
||||
|
||||
/**
|
||||
|
||||
@ -35,13 +35,6 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.DataChangedException;
|
||||
import org.jooq.impl.Factory;
|
||||
|
||||
/**
|
||||
* A record originating from a single table
|
||||
@ -56,207 +49,6 @@ public interface TableRecord<R extends TableRecord<R>> extends Record {
|
||||
*/
|
||||
Table<R> getTable();
|
||||
|
||||
/**
|
||||
* Store this record back to the database.
|
||||
* <p>
|
||||
* Depending on the state of the provided keys' value, an
|
||||
* <code>INSERT</code> or an <code>UPDATE</code> statement is executed.
|
||||
* <p>
|
||||
* <h3>Statement type</h3>
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>If this record was created by client code, an <code>INSERT</code>
|
||||
* statement is executed</li>
|
||||
* <li>If this record was loaded by jOOQ, but the provided keys' value was
|
||||
* changed, an <code>INSERT</code> statement is executed. jOOQ expects that
|
||||
* primary key values will never change due to the principle of
|
||||
* normalisation in RDBMS. So if client code changes primary key values,
|
||||
* this is interpreted by jOOQ as client code wanting to duplicate this
|
||||
* record.</li>
|
||||
* <li>If this record was loaded by jOOQ, and the provided keys' value was
|
||||
* not changed, an <code>UPDATE</code> statement is executed.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* In either statement type, only those fields are inserted/updated, which
|
||||
* had been explicitly set by client code, in order to allow for
|
||||
* <code>DEFAULT</code> values to be applied by the underlying RDBMS. If no
|
||||
* fields were modified, neither an <code>UPDATE</code> nor an
|
||||
* <code>INSERT</code> will be executed.
|
||||
* <h3>Automatic value generation</h3>
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li><strong>IDENTITY columns</strong>
|
||||
* <p>
|
||||
* If there is an <code>IDENTITY</code> column defined on the record's
|
||||
* underlying table (see {@link Table#getIdentity()}), then the
|
||||
* auto-generated <code>IDENTITY</code> value is refreshed automatically on
|
||||
* <code>INSERT</code>'s. Refreshing is done using
|
||||
* {@link Statement#getGeneratedKeys()}, where this is supported by the JDBC
|
||||
* driver. See also {@link InsertQuery#getReturnedRecord()} for more details
|
||||
* </li>
|
||||
* <li><strong>VERSION and TIMESTAMP columns</strong>
|
||||
* <p>
|
||||
* jOOQ can auto-generate "version" and "timestamp" values that can be used
|
||||
* for optimistic locking. If this is an {@link UpdatableRecord} and if this
|
||||
* record returns fields for either
|
||||
* {@link UpdatableTable#getRecordVersion()} or
|
||||
* {@link UpdatableTable#getRecordTimestamp()}, then these values are set
|
||||
* onto the <code>INSERT</code> or <code>UPDATE</code> statement being
|
||||
* executed. On execution success, the generated values are set to this
|
||||
* record. Use the code-generation configuration to specify naming patterns
|
||||
* for auto-generated "version" and "timestamp" columns.
|
||||
* <p>
|
||||
* Should you want to circumvent jOOQ-generated updates to these columns,
|
||||
* you can render an <code>INSERT</code> or <code>UPDATE</code> statement
|
||||
* manually using the various {@link Factory#insertInto(Table)},
|
||||
* {@link Factory#update(Table)} methods.</li>
|
||||
* </ul>
|
||||
* <h3>Optimistic locking</h3>
|
||||
* <p>
|
||||
* If an <code>UPDATE</code> statement is executed and
|
||||
* {@link Settings#isExecuteWithOptimisticLocking()} is set to
|
||||
* <code>true</code>, then this record will first be compared with the
|
||||
* latest state in the database. There are two modes of operation for
|
||||
* optimistic locking:
|
||||
* <ul>
|
||||
* <li><strong>With VERSION and/or TIMESTAMP columns configured</strong>
|
||||
* <p>
|
||||
* This is the preferred way of using optimistic locking in jOOQ. If this is
|
||||
* an {@link UpdatableRecord} and if this record returns fields for either
|
||||
* {@link UpdatableTable#getRecordVersion()} or
|
||||
* {@link UpdatableTable#getRecordTimestamp()}, then these values are
|
||||
* compared to the corresponding value in the database in the
|
||||
* <code>WHERE</code> clause of the executed <code>DELETE</code> statement.</li>
|
||||
* <li><strong>Without any specific column configurations</strong>
|
||||
* <p>
|
||||
* In order to compare this record with the latest state, the database
|
||||
* record will be locked pessimistically using a
|
||||
* <code>SELECT .. FOR UPDATE</code> statement. Not all databases support
|
||||
* the <code>FOR UPDATE</code> clause natively. Namely, the following
|
||||
* databases will show slightly different behaviour:
|
||||
* <ul>
|
||||
* <li> {@link SQLDialect#CUBRID} and {@link SQLDialect#SQLSERVER}: jOOQ will
|
||||
* try to lock the database record using JDBC's
|
||||
* {@link ResultSet#TYPE_SCROLL_SENSITIVE} and
|
||||
* {@link ResultSet#CONCUR_UPDATABLE}.</li>
|
||||
* <li> {@link SQLDialect#SQLITE}: No pessimistic locking is possible. Client
|
||||
* code must assure that no race-conditions can occur between jOOQ's
|
||||
* checking of database record state and the actual <code>UPDATE</code></li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* See {@link LockProvider#setForUpdate(boolean)} for more details</li>
|
||||
* </ul>
|
||||
* <h3>Statement examples</h3>
|
||||
* <p>
|
||||
* Possible statements are
|
||||
* <ul>
|
||||
* <li>
|
||||
* <code><pre>
|
||||
* INSERT INTO [table] ([modified fields, including keys])
|
||||
* VALUES ([modified values, including keys])</pre></code></li>
|
||||
* <li>
|
||||
* <code><pre>
|
||||
* UPDATE [table]
|
||||
* SET [modified fields = modified values, excluding keys]
|
||||
* WHERE [key fields = key values]
|
||||
* AND [version/timestamp fields = version/timestamp values]</pre></code></li>
|
||||
* </ul>
|
||||
*
|
||||
* @param keys The key fields used for deciding whether to execute an
|
||||
* <code>INSERT</code> or <code>UPDATE</code> statement. If an
|
||||
* <code>UPDATE</code> statement is executed, they are also the
|
||||
* key fields for the <code>UPDATE</code> statement's
|
||||
* <code>WHERE</code> clause.
|
||||
* @return The number of stored records.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws DataChangedException If optimistic locking is enabled and the
|
||||
* record has already been changed/deleted in the database
|
||||
* @deprecated - 2.5.0 [#1736] - These methods will be made part of jOOQ's
|
||||
* internal API soon. Do not reuse these methods.
|
||||
*/
|
||||
@Deprecated
|
||||
int storeUsing(TableField<R, ?>... keys) throws DataAccessException, DataChangedException;
|
||||
|
||||
/**
|
||||
* Deletes this record from the database, based on the value of the provided
|
||||
* keys.
|
||||
* <p>
|
||||
* <h3>Optimistic locking</h3>
|
||||
* <p>
|
||||
* If a <code>DELETE</code> statement is executed and
|
||||
* {@link Settings#isExecuteWithOptimisticLocking()} is set to
|
||||
* <code>true</code>, then this record will first be compared with the
|
||||
* latest state in the database. There are two modes of operation for
|
||||
* optimistic locking:
|
||||
* <ul>
|
||||
* <li><strong>With VERSION and/or TIMESTAMP columns configured</strong>
|
||||
* <p>
|
||||
* This is the preferred way of using optimistic locking in jOOQ. If this is
|
||||
* an {@link UpdatableRecord} and if this record returns fields for either
|
||||
* {@link UpdatableTable#getRecordVersion()} or
|
||||
* {@link UpdatableTable#getRecordTimestamp()}, then these values are
|
||||
* compared to the corresponding value in the database in the
|
||||
* <code>WHERE</code> clause of the executed <code>DELETE</code> statement.</li>
|
||||
* <li><strong>Without any specific column configurations</strong>
|
||||
* <p>
|
||||
* In order to compare this record with the latest state, the database
|
||||
* record will be locked pessimistically using a
|
||||
* <code>SELECT .. FOR UPDATE</code> statement. Not all databases support
|
||||
* the <code>FOR UPDATE</code> clause natively. Namely, the following
|
||||
* databases will show slightly different behaviour:
|
||||
* <ul>
|
||||
* <li> {@link SQLDialect#CUBRID} and {@link SQLDialect#SQLSERVER}: jOOQ will
|
||||
* try to lock the database record using JDBC's
|
||||
* {@link ResultSet#TYPE_SCROLL_SENSITIVE} and
|
||||
* {@link ResultSet#CONCUR_UPDATABLE}.</li>
|
||||
* <li> {@link SQLDialect#SQLITE}: No pessimistic locking is possible. Client
|
||||
* code must assure that no race-conditions can occur between jOOQ's
|
||||
* checking of database record state and the actual <code>DELETE</code></li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* See {@link LockProvider#setForUpdate(boolean)} for more details</li>
|
||||
* </ul>
|
||||
* <h3>Statement examples</h3>
|
||||
* <p>
|
||||
* The executed statement is <code><pre>
|
||||
* DELETE FROM [table]
|
||||
* WHERE [key fields = key values]
|
||||
* AND [version/timestamp fields = version/timestamp values]</pre></code>
|
||||
*
|
||||
* @param keys The key fields for the <code>DELETE</code> statement's
|
||||
* <code>WHERE</code> clause.
|
||||
* @return The number of deleted records.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws DataChangedException If optimistic locking is enabled and the
|
||||
* record has already been changed/deleted in the database
|
||||
* @deprecated - 2.5.0 [#1736] - These methods will be made part of jOOQ's
|
||||
* internal API soon. Do not reuse these methods.
|
||||
*/
|
||||
@Deprecated
|
||||
int deleteUsing(TableField<R, ?>... keys) throws DataAccessException, DataChangedException;
|
||||
|
||||
/**
|
||||
* Refresh this record from the database, based on the value of the provided
|
||||
* keys.
|
||||
* <p>
|
||||
* The executed statement is <code><pre>
|
||||
* SELECT * FROM [table]
|
||||
* WHERE [key fields = key values]</pre></code>
|
||||
*
|
||||
* @param keys The key fields for the <code>SELECT</code> statement's
|
||||
* <code>WHERE</code> clause.
|
||||
* @throws DataAccessException This exception is thrown if
|
||||
* <ul>
|
||||
* <li>something went wrong executing the query</li> <li>the
|
||||
* record does not exist anymore in the database</li> <li>the
|
||||
* provided keys return several records.</li>
|
||||
* </ul>
|
||||
* @deprecated - 2.5.0 [#1736] - These methods will be made part of jOOQ's
|
||||
* internal API soon. Do not reuse these methods.
|
||||
*/
|
||||
@Deprecated
|
||||
void refreshUsing(TableField<R, ?>... keys) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@ -46,7 +46,7 @@ package org.jooq;
|
||||
* {@link org.jooq.UDT} with a single interface
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Type<R extends Record> extends NamedQueryPart, FieldProvider, org.jooq.SchemaProvider {
|
||||
public interface Type<R extends Record> extends NamedQueryPart, FieldProvider {
|
||||
|
||||
/**
|
||||
* @return The record type produced by this table
|
||||
|
||||
@ -48,7 +48,6 @@ public interface UDT<R extends UDTRecord<R>> extends org.jooq.Type<R> {
|
||||
/**
|
||||
* Get the UDT schema
|
||||
*/
|
||||
@Override
|
||||
Schema getSchema();
|
||||
|
||||
/**
|
||||
|
||||
@ -40,10 +40,9 @@ import java.util.List;
|
||||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Schema;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
abstract class AbstractFieldProviderQueryPart<R extends Record> extends AbstractSchemaProviderQueryPart implements
|
||||
abstract class AbstractFieldProviderQueryPart<R extends Record> extends AbstractNamedQueryPart implements
|
||||
org.jooq.Type<R> {
|
||||
|
||||
/**
|
||||
@ -51,8 +50,8 @@ abstract class AbstractFieldProviderQueryPart<R extends Record> extends Abstract
|
||||
*/
|
||||
private static final long serialVersionUID = -4629861305735726005L;
|
||||
|
||||
AbstractFieldProviderQueryPart(String name, Schema schema) {
|
||||
super(name, schema);
|
||||
AbstractFieldProviderQueryPart(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -49,7 +49,6 @@ import org.jooq.Param;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.QueryPartInternal;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
|
||||
@ -60,11 +59,6 @@ abstract class AbstractQueryPart implements QueryPartInternal {
|
||||
|
||||
private static final long serialVersionUID = 2078114876079493107L;
|
||||
|
||||
@Override
|
||||
public final <I> I internalAPI(Class<I> internalType) {
|
||||
return internalType.cast(this);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// [#1544] The deprecated Attachable and Attachable internal API
|
||||
// -------------------------------------------------------------------------
|
||||
@ -82,12 +76,6 @@ abstract class AbstractQueryPart implements QueryPartInternal {
|
||||
// The QueryPart and QueryPart internal API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final SQLDialect getDialect() {
|
||||
throw new UnsupportedOperationException("This method is no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is also declared as {@link Query#getSQL()}
|
||||
* <p>
|
||||
@ -227,17 +215,6 @@ abstract class AbstractQueryPart implements QueryPartInternal {
|
||||
return Factory.getNewFactory(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal convenience method
|
||||
*
|
||||
* @deprecated - 2.3.0 - Do not reuse
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
protected final DataAccessException translate(String task, String sql, SQLException e) {
|
||||
return translate(sql, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal convenience method
|
||||
*/
|
||||
|
||||
@ -51,11 +51,6 @@ import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -63,7 +58,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.ArrayRecord;
|
||||
import org.jooq.Attachable;
|
||||
import org.jooq.Converter;
|
||||
import org.jooq.Field;
|
||||
@ -252,138 +246,6 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(Field<?> field) {
|
||||
return getValueAsString(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(Field<?> field, String defaultValue) {
|
||||
return getValueAsString(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(Field<?> field) {
|
||||
return getValueAsByte(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(Field<?> field, Byte defaultValue) {
|
||||
return getValueAsByte(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(Field<?> field) {
|
||||
return getValueAsShort(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(Field<?> field, Short defaultValue) {
|
||||
return getValueAsShort(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(Field<?> field) {
|
||||
return getValueAsInteger(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(Field<?> field, Integer defaultValue) {
|
||||
return getValueAsInteger(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(Field<?> field) {
|
||||
return getValueAsLong(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(Field<?> field, Long defaultValue) {
|
||||
return getValueAsLong(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(Field<?> field) {
|
||||
return getValueAsBigInteger(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(Field<?> field, BigInteger defaultValue)
|
||||
{
|
||||
return getValueAsBigInteger(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(Field<?> field) {
|
||||
return getValueAsFloat(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(Field<?> field, Float defaultValue) {
|
||||
return getValueAsFloat(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(Field<?> field) {
|
||||
return getValueAsDouble(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(Field<?> field, Double defaultValue) {
|
||||
return getValueAsDouble(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(Field<?> field) {
|
||||
return getValueAsBigDecimal(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(Field<?> field, BigDecimal defaultValue)
|
||||
{
|
||||
return getValueAsBigDecimal(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(Field<?> field) {
|
||||
return getValueAsBoolean(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(Field<?> field, Boolean defaultValue) {
|
||||
return getValueAsBoolean(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(Field<?> field) {
|
||||
return getValueAsTimestamp(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(Field<?> field, Timestamp defaultValue) {
|
||||
return getValueAsTimestamp(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(Field<?> field) {
|
||||
return getValueAsDate(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(Field<?> field, Date defaultValue) {
|
||||
return getValueAsDate(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(Field<?> field) {
|
||||
return getValueAsTime(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(Field<?> field, Time defaultValue) {
|
||||
return getValueAsTime(getIndex(field), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object getValue(int index) {
|
||||
return getValue0(index).getValue();
|
||||
@ -400,152 +262,6 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
return getValue((Field<Object>) getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <A extends ArrayRecord<T>, T> T[] getValueAsArray(Field<A> field) {
|
||||
A result = getValue(field);
|
||||
return result == null ? null : result.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <A extends ArrayRecord<T>, T> T[] getValueAsArray(Field<A> field, T[] defaultValue)
|
||||
{
|
||||
final T[] result = getValueAsArray(field);
|
||||
return result == null ? defaultValue : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(String fieldName) {
|
||||
return getValueAsString(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(String fieldName, String defaultValue) {
|
||||
return getValueAsString(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(String fieldName) {
|
||||
return getValueAsByte(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(String fieldName, Byte defaultValue) {
|
||||
return getValueAsByte(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(String fieldName) {
|
||||
return getValueAsShort(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(String fieldName, Short defaultValue) {
|
||||
return getValueAsShort(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(String fieldName) {
|
||||
return getValueAsInteger(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(String fieldName, Integer defaultValue) {
|
||||
return getValueAsInteger(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(String fieldName) {
|
||||
return getValueAsLong(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(String fieldName, Long defaultValue) {
|
||||
return getValueAsLong(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(String fieldName) {
|
||||
return getValueAsBigInteger(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(String fieldName, BigInteger defaultValue)
|
||||
{
|
||||
return getValueAsBigInteger(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(String fieldName) {
|
||||
return getValueAsFloat(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(String fieldName, Float defaultValue) {
|
||||
return getValueAsFloat(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(String fieldName) {
|
||||
return getValueAsDouble(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(String fieldName, Double defaultValue) {
|
||||
return getValueAsDouble(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(String fieldName) {
|
||||
return getValueAsBigDecimal(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(String fieldName, BigDecimal defaultValue)
|
||||
{
|
||||
return getValueAsBigDecimal(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(String fieldName) {
|
||||
return getValueAsBoolean(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(String fieldName, Boolean defaultValue) {
|
||||
return getValueAsBoolean(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(String fieldName) {
|
||||
return getValueAsTimestamp(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(String fieldName, Timestamp defaultValue)
|
||||
{
|
||||
return getValueAsTimestamp(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(String fieldName) {
|
||||
return getValueAsDate(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(String fieldName, Date defaultValue) {
|
||||
return getValueAsDate(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(String fieldName) {
|
||||
return getValueAsTime(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(String fieldName, Time defaultValue) {
|
||||
return getValueAsTime(getField(fieldName), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> T getValue(Field<?> field, Class<? extends T> type) {
|
||||
return Convert.convert(getValue(field), type);
|
||||
|
||||
@ -79,7 +79,7 @@ import org.jooq.tools.Convert;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public abstract class AbstractRoutine<T> extends AbstractSchemaProviderQueryPart implements Routine<T>, AttachableInternal {
|
||||
public abstract class AbstractRoutine<T> extends AbstractNamedQueryPart implements Routine<T>, AttachableInternal {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
@ -90,6 +90,7 @@ public abstract class AbstractRoutine<T> extends AbstractSchemaProviderQueryPart
|
||||
// Meta-data attributes (the same for every call)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private final Schema schema;
|
||||
private final Package pkg;
|
||||
private final List<Parameter<?>> allParameters;
|
||||
private final List<Parameter<?>> inParameters;
|
||||
@ -127,10 +128,11 @@ public abstract class AbstractRoutine<T> extends AbstractSchemaProviderQueryPart
|
||||
}
|
||||
|
||||
protected AbstractRoutine(String name, Schema schema, Package pkg, DataType<T> type) {
|
||||
super(name, schema);
|
||||
super(name);
|
||||
|
||||
this.parameterIndexes = new HashMap<Parameter<?>, Integer>();
|
||||
|
||||
this.schema = schema;
|
||||
this.pkg = pkg;
|
||||
this.allParameters = new ArrayList<Parameter<?>>();
|
||||
this.inParameters = new ArrayList<Parameter<?>>();
|
||||
@ -579,6 +581,11 @@ public abstract class AbstractRoutine<T> extends AbstractSchemaProviderQueryPart
|
||||
return Collections.unmodifiableList(allParameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Schema getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Package getPackage() {
|
||||
return pkg;
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed to you under the Apache License, Version 2.0
|
||||
* (the "License"); You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* . Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* . Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* . Neither the name "jOOQ" nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import org.jooq.Schema;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
abstract class AbstractSchemaProviderQueryPart extends AbstractNamedQueryPart implements org.jooq.SchemaProvider {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -4323244225816421319L;
|
||||
|
||||
private final Schema schema;
|
||||
|
||||
AbstractSchemaProviderQueryPart(String name, Schema schema) {
|
||||
super(name);
|
||||
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Schema getSchema() {
|
||||
return schema;
|
||||
}
|
||||
}
|
||||
@ -73,11 +73,6 @@ abstract class AbstractStore<T> implements Store<T>, AttachableInternal {
|
||||
// The Attachable API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final <I> I internalAPI(Class<I> internalType) {
|
||||
return internalType.cast(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void attach(Configuration c) {
|
||||
configuration = c;
|
||||
|
||||
@ -66,12 +66,16 @@ abstract class AbstractTable<R extends Record> extends AbstractFieldProviderQuer
|
||||
*/
|
||||
private static final long serialVersionUID = 3155496238969274871L;
|
||||
|
||||
private final Schema schema;
|
||||
|
||||
AbstractTable(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
AbstractTable(String name, Schema schema) {
|
||||
super(name, schema);
|
||||
super(name);
|
||||
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -92,6 +96,11 @@ abstract class AbstractTable<R extends Record> extends AbstractFieldProviderQuer
|
||||
// XXX: Table API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Schema getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
|
||||
@ -93,8 +93,8 @@ class BatchStore implements Batch {
|
||||
Settings orig = SettingsTools.clone(work);
|
||||
|
||||
try {
|
||||
// [#1537] Communicate with TableRecordImpl
|
||||
create.setData(TableRecordImpl.OMIT_RETURNING_CLAUSE, true);
|
||||
// [#1537] Communicate with UpdatableRecordImpl
|
||||
create.setData(UpdatableRecordImpl.OMIT_RETURNING_CLAUSE, true);
|
||||
|
||||
// Add the QueryCollector to intercept query execution after rendering
|
||||
work.setExecuteListeners(Arrays.asList(QueryCollector.class.getName()));
|
||||
@ -133,7 +133,7 @@ class BatchStore implements Batch {
|
||||
|
||||
// Restore the original factory
|
||||
finally {
|
||||
create.getData().remove(TableRecordImpl.OMIT_RETURNING_CLAUSE);
|
||||
create.getData().remove(UpdatableRecordImpl.OMIT_RETURNING_CLAUSE);
|
||||
|
||||
work.setExecuteListeners(orig.getExecuteListeners());
|
||||
work.setExecuteLogging(orig.isExecuteLogging());
|
||||
|
||||
@ -51,15 +51,24 @@ import org.jooq.Schema;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public class PackageImpl extends AbstractSchemaProviderQueryPart implements Package {
|
||||
public class PackageImpl extends AbstractNamedQueryPart implements Package {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 7466890004995197675L;
|
||||
|
||||
private final Schema schema;
|
||||
|
||||
public PackageImpl(String name, Schema schema) {
|
||||
super(name, schema);
|
||||
super(name);
|
||||
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Schema getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -43,12 +43,7 @@ import static org.jooq.tools.StringUtils.leftPad;
|
||||
import static org.jooq.tools.StringUtils.rightPad;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -64,7 +59,6 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.jooq.ArrayRecord;
|
||||
import org.jooq.Attachable;
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
@ -112,11 +106,6 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
// XXX: Attachable API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final <I> I internalAPI(Class<I> internalType) {
|
||||
return internalType.cast(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void attach(Configuration c) {
|
||||
this.configuration = c;
|
||||
@ -214,406 +203,6 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
return get(index).getValue(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <A extends ArrayRecord<T>, T> T[] getValueAsArray(int index, Field<A> field) {
|
||||
return get(index).getValueAsArray(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <A extends ArrayRecord<T>, T> T[] getValueAsArray(int index, Field<A> field, T[] defaultValue) {
|
||||
return get(index).getValueAsArray(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(int index, Field<?> field) {
|
||||
return get(index).getValueAsString(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(int index, Field<?> field, String defaultValue) {
|
||||
return get(index).getValueAsString(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(int index, int fieldIndex) {
|
||||
return get(index).getValueAsString(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(int index, int fieldIndex, String defaultValue) {
|
||||
return get(index).getValueAsString(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(int index, Field<?> field) {
|
||||
return get(index).getValueAsByte(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(int index, Field<?> field, Byte defaultValue) {
|
||||
return get(index).getValueAsByte(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(int index, int fieldIndex) {
|
||||
return get(index).getValueAsByte(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(int index, int fieldIndex, Byte defaultValue) {
|
||||
return get(index).getValueAsByte(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(int index, Field<?> field) {
|
||||
return get(index).getValueAsShort(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(int index, Field<?> field, Short defaultValue) {
|
||||
return get(index).getValueAsShort(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(int index, int fieldIndex) {
|
||||
return get(index).getValueAsShort(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(int index, int fieldIndex, Short defaultValue) {
|
||||
return get(index).getValueAsShort(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(int index, Field<?> field) {
|
||||
return get(index).getValueAsInteger(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(int index, Field<?> field, Integer defaultValue) {
|
||||
return get(index).getValueAsInteger(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(int index, int fieldIndex) {
|
||||
return get(index).getValueAsInteger(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(int index, int fieldIndex, Integer defaultValue) {
|
||||
return get(index).getValueAsInteger(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(int index, Field<?> field) {
|
||||
return get(index).getValueAsLong(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(int index, Field<?> field, Long defaultValue) {
|
||||
return get(index).getValueAsLong(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(int index, int fieldIndex) {
|
||||
return get(index).getValueAsLong(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(int index, int fieldIndex, Long defaultValue) {
|
||||
return get(index).getValueAsLong(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(int index, Field<?> field) {
|
||||
return get(index).getValueAsBigInteger(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(int index, Field<?> field, BigInteger defaultValue) {
|
||||
return get(index).getValueAsBigInteger(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(int index, int fieldIndex) {
|
||||
return get(index).getValueAsBigInteger(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(int index, int fieldIndex, BigInteger defaultValue) {
|
||||
return get(index).getValueAsBigInteger(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(int index, Field<?> field) {
|
||||
return get(index).getValueAsFloat(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(int index, Field<?> field, Float defaultValue) {
|
||||
return get(index).getValueAsFloat(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(int index, int fieldIndex) {
|
||||
return get(index).getValueAsFloat(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(int index, int fieldIndex, Float defaultValue) {
|
||||
return get(index).getValueAsFloat(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(int index, Field<?> field) {
|
||||
return get(index).getValueAsDouble(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(int index, Field<?> field, Double defaultValue) {
|
||||
return get(index).getValueAsDouble(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(int index, int fieldIndex) {
|
||||
return get(index).getValueAsDouble(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(int index, int fieldIndex, Double defaultValue) {
|
||||
return get(index).getValueAsDouble(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(int index, Field<?> field) {
|
||||
return get(index).getValueAsBigDecimal(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(int index, Field<?> field, BigDecimal defaultValue) {
|
||||
return get(index).getValueAsBigDecimal(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(int index, int fieldIndex) {
|
||||
return get(index).getValueAsBigDecimal(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(int index, int fieldIndex, BigDecimal defaultValue) {
|
||||
return get(index).getValueAsBigDecimal(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(int index, Field<?> field) {
|
||||
return get(index).getValueAsBoolean(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(int index, Field<?> field, Boolean defaultValue) {
|
||||
return get(index).getValueAsBoolean(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(int index, int fieldIndex) {
|
||||
return get(index).getValueAsBoolean(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(int index, int fieldIndex, Boolean defaultValue) {
|
||||
return get(index).getValueAsBoolean(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(int index, Field<?> field) {
|
||||
return get(index).getValueAsTimestamp(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(int index, Field<?> field, Timestamp defaultValue) {
|
||||
return get(index).getValueAsTimestamp(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(int index, int fieldIndex) {
|
||||
return get(index).getValueAsTimestamp(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(int index, int fieldIndex, Timestamp defaultValue) {
|
||||
return get(index).getValueAsTimestamp(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(int index, Field<?> field) {
|
||||
return get(index).getValueAsDate(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(int index, Field<?> field, Date defaultValue) {
|
||||
return get(index).getValueAsDate(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(int index, int fieldIndex) {
|
||||
return get(index).getValueAsDate(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(int index, int fieldIndex, Date defaultValue) {
|
||||
return get(index).getValueAsDate(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(int index, Field<?> field) {
|
||||
return get(index).getValueAsTime(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(int index, Field<?> field, Time defaultValue) {
|
||||
return get(index).getValueAsTime(field, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(int index, int fieldIndex) {
|
||||
return get(index).getValueAsTime(fieldIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(int index, int fieldIndex, Time defaultValue) {
|
||||
return get(index).getValueAsTime(fieldIndex, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(int index, String fieldName) {
|
||||
return get(index).getValueAsString(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getValueAsString(int index, String fieldName, String defaultValue) {
|
||||
return get(index).getValueAsString(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(int index, String fieldName) {
|
||||
return get(index).getValueAsByte(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Byte getValueAsByte(int index, String fieldName, Byte defaultValue) {
|
||||
return get(index).getValueAsByte(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(int index, String fieldName) {
|
||||
return get(index).getValueAsShort(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Short getValueAsShort(int index, String fieldName, Short defaultValue) {
|
||||
return get(index).getValueAsShort(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(int index, String fieldName) {
|
||||
return get(index).getValueAsInteger(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getValueAsInteger(int index, String fieldName, Integer defaultValue) {
|
||||
return get(index).getValueAsInteger(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(int index, String fieldName) {
|
||||
return get(index).getValueAsLong(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Long getValueAsLong(int index, String fieldName, Long defaultValue) {
|
||||
return get(index).getValueAsLong(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(int index, String fieldName) {
|
||||
return get(index).getValueAsBigInteger(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigInteger getValueAsBigInteger(int index, String fieldName, BigInteger defaultValue) {
|
||||
return get(index).getValueAsBigInteger(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(int index, String fieldName) {
|
||||
return get(index).getValueAsFloat(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Float getValueAsFloat(int index, String fieldName, Float defaultValue) {
|
||||
return get(index).getValueAsFloat(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(int index, String fieldName) {
|
||||
return get(index).getValueAsDouble(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Double getValueAsDouble(int index, String fieldName, Double defaultValue) {
|
||||
return get(index).getValueAsDouble(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(int index, String fieldName) {
|
||||
return get(index).getValueAsBigDecimal(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BigDecimal getValueAsBigDecimal(int index, String fieldName, BigDecimal defaultValue) {
|
||||
return get(index).getValueAsBigDecimal(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(int index, String fieldName) {
|
||||
return get(index).getValueAsBoolean(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getValueAsBoolean(int index, String fieldName, Boolean defaultValue) {
|
||||
return get(index).getValueAsBoolean(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(int index, String fieldName) {
|
||||
return get(index).getValueAsTimestamp(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Timestamp getValueAsTimestamp(int index, String fieldName, Timestamp defaultValue) {
|
||||
return get(index).getValueAsTimestamp(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(int index, String fieldName) {
|
||||
return get(index).getValueAsDate(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Date getValueAsDate(int index, String fieldName, Date defaultValue) {
|
||||
return get(index).getValueAsDate(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(int index, String fieldName) {
|
||||
return get(index).getValueAsTime(fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Time getValueAsTime(int index, String fieldName, Time defaultValue) {
|
||||
return get(index).getValueAsTime(fieldName, defaultValue);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final <T> List<T> getValues(Field<T> field) {
|
||||
@ -666,258 +255,6 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
return Convert.convert(getValues(fieldName), converter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<BigDecimal> getValuesAsBigDecimal(Field<?> field) {
|
||||
List<BigDecimal> result = new ArrayList<BigDecimal>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsBigDecimal(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<BigDecimal> getValuesAsBigDecimal(int fieldIndex) {
|
||||
return getValuesAsBigDecimal(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<BigInteger> getValuesAsBigInteger(Field<?> field) {
|
||||
List<BigInteger> result = new ArrayList<BigInteger>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsBigInteger(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<BigInteger> getValuesAsBigInteger(int fieldIndex) {
|
||||
return getValuesAsBigInteger(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Byte> getValuesAsByte(Field<?> field) {
|
||||
List<Byte> result = new ArrayList<Byte>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsByte(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Byte> getValuesAsByte(int fieldIndex) {
|
||||
return getValuesAsByte(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Date> getValuesAsDate(Field<?> field) {
|
||||
List<Date> result = new ArrayList<Date>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsDate(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Date> getValuesAsDate(int fieldIndex) {
|
||||
return getValuesAsDate(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Double> getValuesAsDouble(Field<?> field) {
|
||||
List<Double> result = new ArrayList<Double>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsDouble(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Double> getValuesAsDouble(int fieldIndex) {
|
||||
return getValuesAsDouble(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Float> getValuesAsFloat(Field<?> field) {
|
||||
List<Float> result = new ArrayList<Float>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsFloat(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Float> getValuesAsFloat(int fieldIndex) {
|
||||
return getValuesAsFloat(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Integer> getValuesAsInteger(Field<?> field) {
|
||||
List<Integer> result = new ArrayList<Integer>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsInteger(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Integer> getValuesAsInteger(int fieldIndex) {
|
||||
return getValuesAsInteger(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Long> getValuesAsLong(Field<?> field) {
|
||||
List<Long> result = new ArrayList<Long>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsLong(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Long> getValuesAsLong(int fieldIndex) {
|
||||
return getValuesAsLong(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Short> getValuesAsShort(Field<?> field) {
|
||||
List<Short> result = new ArrayList<Short>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsShort(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Short> getValuesAsShort(int fieldIndex) {
|
||||
return getValuesAsShort(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<String> getValuesAsString(Field<?> field) {
|
||||
List<String> result = new ArrayList<String>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsString(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<String> getValuesAsString(int fieldIndex) {
|
||||
return getValuesAsString(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Time> getValuesAsTime(Field<?> field) {
|
||||
List<Time> result = new ArrayList<Time>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsTime(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Time> getValuesAsTime(int fieldIndex) {
|
||||
return getValuesAsTime(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Timestamp> getValuesAsTimestamp(Field<?> field) {
|
||||
List<Timestamp> result = new ArrayList<Timestamp>(size());
|
||||
|
||||
for (R record : this) {
|
||||
result.add(record.getValueAsTimestamp(field));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Timestamp> getValuesAsTimestamp(int fieldIndex) {
|
||||
return getValuesAsTimestamp(getField(fieldIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<BigDecimal> getValuesAsBigDecimal(String fieldName) {
|
||||
return getValuesAsBigDecimal(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<BigInteger> getValuesAsBigInteger(String fieldName) {
|
||||
return getValuesAsBigInteger(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Byte> getValuesAsByte(String fieldName) {
|
||||
return getValuesAsByte(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Date> getValuesAsDate(String fieldName) {
|
||||
return getValuesAsDate(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Double> getValuesAsDouble(String fieldName) {
|
||||
return getValuesAsDouble(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Float> getValuesAsFloat(String fieldName) {
|
||||
return getValuesAsFloat(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Integer> getValuesAsInteger(String fieldName) {
|
||||
return getValuesAsInteger(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Long> getValuesAsLong(String fieldName) {
|
||||
return getValuesAsLong(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Short> getValuesAsShort(String fieldName) {
|
||||
return getValuesAsShort(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<String> getValuesAsString(String fieldName) {
|
||||
return getValuesAsString(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Time> getValuesAsTime(String fieldName) {
|
||||
return getValuesAsTime(getField(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Timestamp> getValuesAsTimestamp(String fieldName) {
|
||||
return getValuesAsTimestamp(getField(fieldName));
|
||||
}
|
||||
|
||||
final void addRecord(R record) {
|
||||
records.add(record);
|
||||
}
|
||||
@ -1314,11 +651,6 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Document exportXML() {
|
||||
return intoXML();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Document intoXML() {
|
||||
final int size = getFields().size();
|
||||
|
||||
@ -37,9 +37,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.RenderContext;
|
||||
@ -59,13 +57,8 @@ public class SchemaImpl extends AbstractNamedQueryPart implements Schema {
|
||||
|
||||
private static final long serialVersionUID = -8101463810207566546L;
|
||||
|
||||
@Deprecated
|
||||
private final Map<String, Class<?>> typeMapping;
|
||||
|
||||
public SchemaImpl(String name) {
|
||||
super(name);
|
||||
|
||||
this.typeMapping = new HashMap<String, Class<?>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,20 +69,6 @@ public class SchemaImpl extends AbstractNamedQueryPart implements Schema {
|
||||
context.literal(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Map<String, Class<?>> getTypeMapping() {
|
||||
return Collections.unmodifiableMap(typeMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - 2.3.0 - regenerate your schema
|
||||
*/
|
||||
@Deprecated
|
||||
protected final void addMapping(String name, Class<?> recordType) {
|
||||
typeMapping.put(name, recordType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Table<?> getTable(String name) {
|
||||
for (Table<?> table : getTables()) {
|
||||
|
||||
@ -47,33 +47,21 @@ enum SubQueryOperator {
|
||||
NOT_IN("not in"),
|
||||
EQUALS("="),
|
||||
EQUALS_ANY("= any"),
|
||||
@Deprecated
|
||||
EQUALS_SOME("= some"),
|
||||
EQUALS_ALL("= all"),
|
||||
NOT_EQUALS("<>"),
|
||||
NOT_EQUALS_ANY("<> any"),
|
||||
@Deprecated
|
||||
NOT_EQUALS_SOME("<> some"),
|
||||
NOT_EQUALS_ALL("<> all"),
|
||||
LESS("<"),
|
||||
LESS_THAN_ANY("< any"),
|
||||
@Deprecated
|
||||
LESS_THAN_SOME("< some"),
|
||||
LESS_THAN_ALL("< all"),
|
||||
LESS_OR_EQUAL("<="),
|
||||
LESS_OR_EQUAL_ANY("<= any"),
|
||||
@Deprecated
|
||||
LESS_OR_EQUAL_SOME("<= some"),
|
||||
LESS_OR_EQUAL_ALL("<= all"),
|
||||
GREATER(">"),
|
||||
GREATER_THAN_ANY("> any"),
|
||||
@Deprecated
|
||||
GREATER_THAN_SOME("> some"),
|
||||
GREATER_THAN_ALL("> all"),
|
||||
GREATER_OR_EQUAL(">="),
|
||||
GREATER_OR_EQUAL_ANY(">= any"),
|
||||
@Deprecated
|
||||
GREATER_OR_EQUAL_SOME(">= some"),
|
||||
GREATER_OR_EQUAL_ALL(">= all"), ;
|
||||
|
||||
private final String sql;
|
||||
|
||||
@ -35,31 +35,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.jooq.impl.Factory.val;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.DeleteQuery;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Identity;
|
||||
import org.jooq.InsertQuery;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.SimpleSelectQuery;
|
||||
import org.jooq.StoreQuery;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableRecord;
|
||||
import org.jooq.UpdatableRecord;
|
||||
import org.jooq.UpdatableTable;
|
||||
import org.jooq.UpdateQuery;
|
||||
import org.jooq.exception.DataChangedException;
|
||||
import org.jooq.exception.InvalidResultException;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* A record implementation for a record originating from a single table
|
||||
@ -73,14 +50,7 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 3216746611562261641L;
|
||||
|
||||
/**
|
||||
* [#1537] This constant is used internally by jOOQ to omit the RETURNING
|
||||
* clause in {@link Factory#batchStore(UpdatableRecord...)} calls for
|
||||
* {@link SQLDialect#POSTGRES}
|
||||
*/
|
||||
static final String OMIT_RETURNING_CLAUSE = "JOOQ.OMIT_RETURNING_CLAUSE";
|
||||
private static final long serialVersionUID = 3216746611562261641L;
|
||||
|
||||
public TableRecordImpl(Table<R> table) {
|
||||
super(table);
|
||||
@ -101,356 +71,4 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
|
||||
public final R original() {
|
||||
return (R) super.original();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses may override this method to provide an identity
|
||||
*/
|
||||
Collection<Field<?>> getReturning() {
|
||||
Collection<Field<?>> result = new LinkedHashSet<Field<?>>();
|
||||
|
||||
Identity<R, ?> identity = getTable().getIdentity();
|
||||
if (identity != null) {
|
||||
result.add(identity.getField());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience casting method, in case it is known that casting will succeed
|
||||
*/
|
||||
UpdatableTable<R> getUpdatableTable() {
|
||||
return (UpdatableTable<R>) getTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int storeUsing(TableField<R, ?>... keys) {
|
||||
boolean executeUpdate = false;
|
||||
|
||||
for (TableField<R, ?> field : keys) {
|
||||
|
||||
// If any primary key value is null or changed, execute an insert
|
||||
if (getValue(field) == null || getValue0(field).isChanged()) {
|
||||
executeUpdate = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// If primary key values are unchanged, updates are possible
|
||||
else {
|
||||
executeUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
|
||||
if (executeUpdate) {
|
||||
result = storeUpdate(keys);
|
||||
}
|
||||
else {
|
||||
result = storeInsert();
|
||||
}
|
||||
|
||||
setAllChanged(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
private final boolean isExecuteWithOptimisticLocking() {
|
||||
Configuration configuration = getConfiguration();
|
||||
|
||||
// This can be null when the current record is detached
|
||||
if (configuration != null) {
|
||||
return TRUE.equals(configuration.getSettings().isExecuteWithOptimisticLocking());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private final int storeInsert() {
|
||||
Factory create = create();
|
||||
InsertQuery<R> insert = create.insertQuery(getTable());
|
||||
addChangedValues(insert);
|
||||
|
||||
// Don't store records if no value was set by client code
|
||||
if (!insert.isExecutable()) return 0;
|
||||
|
||||
// [#1596] Set timestamp and/or version columns to appropriate values
|
||||
BigInteger version = addRecordVersion(insert);
|
||||
Timestamp timestamp = addRecordTimestamp(insert);
|
||||
|
||||
// [#814] Refresh identity and/or main unique key values
|
||||
// [#1002] Consider also identity columns of non-updatable records
|
||||
// [#1537] Avoid refreshing identity columns on batch inserts
|
||||
Collection<Field<?>> key = null;
|
||||
if (!TRUE.equals(create.getData(OMIT_RETURNING_CLAUSE))) {
|
||||
key = getReturning();
|
||||
insert.setReturning(key);
|
||||
}
|
||||
|
||||
int result = insert.execute();
|
||||
|
||||
if (result > 0) {
|
||||
|
||||
// [#1596] If insert was successful, update timestamp and/or version columns
|
||||
setRecordVersionAndTimestamp(version, timestamp);
|
||||
|
||||
// If an insert was successful try fetching the generated IDENTITY value
|
||||
if (key != null && !key.isEmpty()) {
|
||||
if (insert.getReturnedRecord() != null) {
|
||||
for (Field<?> field : key) {
|
||||
setValue0(field, new Value<Object>(insert.getReturnedRecord().getValue(field)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private final int storeUpdate(TableField<R, ?>[] keys) {
|
||||
UpdateQuery<R> update = create().updateQuery(getTable());
|
||||
addChangedValues(update);
|
||||
Util.addConditions(update, this, keys);
|
||||
|
||||
// Don't store records if no value was set by client code
|
||||
if (!update.isExecutable()) return 0;
|
||||
|
||||
// [#1596] Set timestamp and/or version columns to appropriate values
|
||||
BigInteger version = addRecordVersion(update);
|
||||
Timestamp timestamp = addRecordTimestamp(update);
|
||||
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
|
||||
// [#1596] Add additional conditions for version and/or timestamp columns
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
addConditionForVersionAndTimestamp(update);
|
||||
}
|
||||
|
||||
// [#1547] Try fetching the Record again first, and compare this
|
||||
// Record's original values with the ones in the database
|
||||
else {
|
||||
checkIfChanged(keys);
|
||||
}
|
||||
}
|
||||
|
||||
// [#1596] Check if the record was really changed in the database
|
||||
int result = update.execute();
|
||||
checkIfChanged(result, version, timestamp);
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private final void addConditionForVersionAndTimestamp(org.jooq.ConditionProvider query) {
|
||||
TableField<R, ?> v = getUpdatableTable().getRecordVersion();
|
||||
TableField<R, ?> t = getUpdatableTable().getRecordTimestamp();
|
||||
|
||||
if (v != null) Util.addCondition(query, this, v);
|
||||
if (t != null) Util.addCondition(query, this, t);
|
||||
}
|
||||
|
||||
private final boolean isTimestampOrVersionAvailable() {
|
||||
if (getTable() instanceof UpdatableTable) {
|
||||
UpdatableTable<R> table = (UpdatableTable<R>) getTable();
|
||||
|
||||
return table.getRecordTimestamp() != null || table.getRecordVersion() != null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int deleteUsing(TableField<R, ?>... keys) {
|
||||
try {
|
||||
DeleteQuery<R> delete = create().deleteQuery(getTable());
|
||||
Util.addConditions(delete, this, keys);
|
||||
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
|
||||
// [#1596] Add additional conditions for version and/or timestamp columns
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
addConditionForVersionAndTimestamp(delete);
|
||||
}
|
||||
|
||||
// [#1547] Try fetching the Record again first, and compare this
|
||||
// Record's original values with the ones in the database
|
||||
else {
|
||||
checkIfChanged(keys);
|
||||
}
|
||||
}
|
||||
|
||||
int result = delete.execute();
|
||||
checkIfChanged(result, null, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
// [#673] If store() is called after delete(), a new INSERT should
|
||||
// be executed and the record should be recreated
|
||||
finally {
|
||||
for (Field<?> field : getFields()) {
|
||||
getValue0(field).setChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void refreshUsing(TableField<R, ?>... keys) {
|
||||
SimpleSelectQuery<R> select = create().selectQuery(getTable());
|
||||
Util.addConditions(select, this, keys);
|
||||
|
||||
if (select.execute() == 1) {
|
||||
AbstractRecord record = (AbstractRecord) select.getResult().get(0);
|
||||
|
||||
for (Field<?> field : getFields()) {
|
||||
setValue0(field, record.getValue0(field));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new InvalidResultException("Exactly one row expected for refresh. Record does not exist in database.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an additional SELECT .. FOR UPDATE to check if the underlying
|
||||
* database record has been changed compared to this record.
|
||||
*/
|
||||
private final void checkIfChanged(TableField<R, ?>[] keys) {
|
||||
SimpleSelectQuery<R> select = create().selectQuery(getTable());
|
||||
Util.addConditions(select, this, keys);
|
||||
|
||||
// [#1547] SQLite doesn't support FOR UPDATE. CUBRID and SQL Server
|
||||
// can simulate it, though!
|
||||
if (create().getDialect() != SQLDialect.SQLITE) {
|
||||
select.setForUpdate(true);
|
||||
}
|
||||
|
||||
R record = select.fetchOne();
|
||||
|
||||
if (record == null) {
|
||||
throw new DataChangedException("Database record no longer exists");
|
||||
}
|
||||
|
||||
for (Field<?> field : getFields()) {
|
||||
Value<?> thisValue = getValue0(field);
|
||||
Value<?> thatValue = ((AbstractRecord) record).getValue0(field);
|
||||
|
||||
Object thisObject = thisValue.getOriginal();
|
||||
Object thatObject = thatValue.getOriginal();
|
||||
|
||||
if (!StringUtils.equals(thisObject, thatObject)) {
|
||||
throw new DataChangedException("Database record has been changed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a database record was changed in the database.
|
||||
*/
|
||||
private final void checkIfChanged(int result, BigInteger version, Timestamp timestamp) {
|
||||
|
||||
// [#1596] If update/delete was successful, update version and/or
|
||||
// timestamp columns.
|
||||
// [#673] Do this also for deletions, in case a deleted record is re-added
|
||||
if (result > 0) {
|
||||
setRecordVersionAndTimestamp(version, timestamp);
|
||||
}
|
||||
|
||||
// [#1596] No records were updated due to version and/or timestamp change
|
||||
else if (isExecuteWithOptimisticLocking()) {
|
||||
throw new DataChangedException("Database record has been changed or doesn't exist any longer");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted method to ensure generic type safety.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private final <T> void setValue0(Field<T> field, Value<?> value) {
|
||||
setValue(field, (Value<T>) value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all changed values of this record to a store query
|
||||
*/
|
||||
private final void addChangedValues(StoreQuery<R> query) {
|
||||
for (Field<?> field : getFields()) {
|
||||
if (getValue0(field).isChanged()) {
|
||||
addValue(query, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted method to ensure generic type safety.
|
||||
*/
|
||||
private final <T> void addValue(StoreQuery<?> store, Field<T> field) {
|
||||
addValue(store, field, getValue(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted method to ensure generic type safety.
|
||||
*/
|
||||
private final <T> void addValue(StoreQuery<?> store, Field<T> field, Object value) {
|
||||
store.addValue(field, val(value, field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an updated timestamp value to a store query
|
||||
*/
|
||||
private final Timestamp addRecordTimestamp(StoreQuery<?> store) {
|
||||
Timestamp result = null;
|
||||
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
TableField<R, ? extends java.util.Date> timestamp = getUpdatableTable().getRecordTimestamp();
|
||||
|
||||
if (timestamp != null) {
|
||||
|
||||
// Use Timestamp locally, to provide maximum precision
|
||||
result = new Timestamp(System.currentTimeMillis());
|
||||
addValue(store, timestamp, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an updated version value to a store query
|
||||
*/
|
||||
private final BigInteger addRecordVersion(StoreQuery<?> store) {
|
||||
BigInteger result = null;
|
||||
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
TableField<R, ? extends Number> version = getUpdatableTable().getRecordVersion();
|
||||
|
||||
if (version != null) {
|
||||
Number value = getValue(version);
|
||||
|
||||
// Use BigInteger locally to avoid arithmetic overflows
|
||||
if (value == null) {
|
||||
result = BigInteger.ONE;
|
||||
}
|
||||
else {
|
||||
result = new BigInteger(value.toString()).add(BigInteger.ONE);
|
||||
}
|
||||
|
||||
addValue(store, version, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a generated version and timestamp value onto this record after
|
||||
* successfully storing the record.
|
||||
*/
|
||||
private final void setRecordVersionAndTimestamp(BigInteger version, Timestamp timestamp) {
|
||||
if (version != null) {
|
||||
TableField<R, ?> field = getUpdatableTable().getRecordVersion();
|
||||
setValue0(field, new Value<Object>(field.getDataType().convert(version)));
|
||||
}
|
||||
if (timestamp != null) {
|
||||
TableField<R, ?> field = getUpdatableTable().getRecordTimestamp();
|
||||
setValue0(field, new Value<Object>(field.getDataType().convert(timestamp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,8 +35,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.QueryPart;
|
||||
@ -56,17 +54,22 @@ import org.jooq.UDTRecord;
|
||||
*/
|
||||
public class UDTImpl<R extends UDTRecord<R>> extends AbstractFieldProviderQueryPart<R> implements UDT<R> {
|
||||
|
||||
private static final long serialVersionUID = -2208672099190913126L;
|
||||
private static final long serialVersionUID = -2208672099190913126L;
|
||||
|
||||
private final FieldList fields;
|
||||
private transient DataType<R> type;
|
||||
@Deprecated
|
||||
private transient Map<String, Class<?>> typeMapping;
|
||||
private final Schema schema;
|
||||
private final FieldList fields;
|
||||
private transient DataType<R> type;
|
||||
|
||||
public UDTImpl(String name, Schema schema) {
|
||||
super(name, schema);
|
||||
super(name);
|
||||
|
||||
this.fields = new FieldList();
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Schema getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,15 +35,32 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.jooq.impl.Factory.val;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.DeleteQuery;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Identity;
|
||||
import org.jooq.InsertQuery;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.SimpleSelectQuery;
|
||||
import org.jooq.StoreQuery;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.UpdatableRecord;
|
||||
import org.jooq.UpdatableTable;
|
||||
import org.jooq.UpdateQuery;
|
||||
import org.jooq.exception.DataChangedException;
|
||||
import org.jooq.exception.InvalidResultException;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* A record implementation for a record holding a primary key
|
||||
@ -57,7 +74,14 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -1012420583600561579L;
|
||||
private static final long serialVersionUID = -1012420583600561579L;
|
||||
|
||||
/**
|
||||
* [#1537] This constant is used internally by jOOQ to omit the RETURNING
|
||||
* clause in {@link Factory#batchStore(UpdatableRecord...)} calls for
|
||||
* {@link SQLDialect#POSTGRES}
|
||||
*/
|
||||
static final String OMIT_RETURNING_CLAUSE = "JOOQ.OMIT_RETURNING_CLAUSE";
|
||||
|
||||
public UpdatableRecordImpl(UpdatableTable<R> table) {
|
||||
super(table);
|
||||
@ -75,22 +99,242 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
|
||||
@Override
|
||||
public final int store() {
|
||||
return storeUsing(getMainKey().getFieldsArray());
|
||||
TableField<R, ?>[] keys = getMainKey().getFieldsArray();
|
||||
boolean executeUpdate = false;
|
||||
|
||||
for (TableField<R, ?> field : keys) {
|
||||
|
||||
// If any primary key value is null or changed, execute an insert
|
||||
if (getValue(field) == null || getValue0(field).isChanged()) {
|
||||
executeUpdate = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// If primary key values are unchanged, updates are possible
|
||||
else {
|
||||
executeUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
|
||||
if (executeUpdate) {
|
||||
result = storeUpdate(keys);
|
||||
}
|
||||
else {
|
||||
result = storeInsert();
|
||||
}
|
||||
|
||||
setAllChanged(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
private final int storeInsert() {
|
||||
Factory create = create();
|
||||
InsertQuery<R> insert = create.insertQuery(getTable());
|
||||
addChangedValues(insert);
|
||||
|
||||
// Don't store records if no value was set by client code
|
||||
if (!insert.isExecutable()) return 0;
|
||||
|
||||
// [#1596] Set timestamp and/or version columns to appropriate values
|
||||
BigInteger version = addRecordVersion(insert);
|
||||
Timestamp timestamp = addRecordTimestamp(insert);
|
||||
|
||||
// [#814] Refresh identity and/or main unique key values
|
||||
// [#1002] Consider also identity columns of non-updatable records
|
||||
// [#1537] Avoid refreshing identity columns on batch inserts
|
||||
Collection<Field<?>> key = null;
|
||||
if (!TRUE.equals(create.getData(OMIT_RETURNING_CLAUSE))) {
|
||||
key = getReturning();
|
||||
insert.setReturning(key);
|
||||
}
|
||||
|
||||
int result = insert.execute();
|
||||
|
||||
if (result > 0) {
|
||||
|
||||
// [#1596] If insert was successful, update timestamp and/or version columns
|
||||
setRecordVersionAndTimestamp(version, timestamp);
|
||||
|
||||
// If an insert was successful try fetching the generated IDENTITY value
|
||||
if (key != null && !key.isEmpty()) {
|
||||
if (insert.getReturnedRecord() != null) {
|
||||
for (Field<?> field : key) {
|
||||
setValue0(field, new Value<Object>(insert.getReturnedRecord().getValue(field)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private final int storeUpdate(TableField<R, ?>[] keys) {
|
||||
UpdateQuery<R> update = create().updateQuery(getTable());
|
||||
addChangedValues(update);
|
||||
Util.addConditions(update, this, keys);
|
||||
|
||||
// Don't store records if no value was set by client code
|
||||
if (!update.isExecutable()) return 0;
|
||||
|
||||
// [#1596] Set timestamp and/or version columns to appropriate values
|
||||
BigInteger version = addRecordVersion(update);
|
||||
Timestamp timestamp = addRecordTimestamp(update);
|
||||
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
|
||||
// [#1596] Add additional conditions for version and/or timestamp columns
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
addConditionForVersionAndTimestamp(update);
|
||||
}
|
||||
|
||||
// [#1547] Try fetching the Record again first, and compare this
|
||||
// Record's original values with the ones in the database
|
||||
else {
|
||||
checkIfChanged(keys);
|
||||
}
|
||||
}
|
||||
|
||||
// [#1596] Check if the record was really changed in the database
|
||||
int result = update.execute();
|
||||
checkIfChanged(result, version, timestamp);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all changed values of this record to a store query
|
||||
*/
|
||||
private final void addChangedValues(StoreQuery<R> query) {
|
||||
for (Field<?> field : getFields()) {
|
||||
if (getValue0(field).isChanged()) {
|
||||
addValue(query, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted method to ensure generic type safety.
|
||||
*/
|
||||
private final <T> void addValue(StoreQuery<?> store, Field<T> field, Object value) {
|
||||
store.addValue(field, val(value, field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted method to ensure generic type safety.
|
||||
*/
|
||||
private final <T> void addValue(StoreQuery<?> store, Field<T> field) {
|
||||
addValue(store, field, getValue(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an updated timestamp value to a store query
|
||||
*/
|
||||
private final Timestamp addRecordTimestamp(StoreQuery<?> store) {
|
||||
Timestamp result = null;
|
||||
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
TableField<R, ? extends java.util.Date> timestamp = getTable().getRecordTimestamp();
|
||||
|
||||
if (timestamp != null) {
|
||||
|
||||
// Use Timestamp locally, to provide maximum precision
|
||||
result = new Timestamp(System.currentTimeMillis());
|
||||
addValue(store, timestamp, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an updated version value to a store query
|
||||
*/
|
||||
private final BigInteger addRecordVersion(StoreQuery<?> store) {
|
||||
BigInteger result = null;
|
||||
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
TableField<R, ? extends Number> version = getTable().getRecordVersion();
|
||||
|
||||
if (version != null) {
|
||||
Number value = getValue(version);
|
||||
|
||||
// Use BigInteger locally to avoid arithmetic overflows
|
||||
if (value == null) {
|
||||
result = BigInteger.ONE;
|
||||
}
|
||||
else {
|
||||
result = new BigInteger(value.toString()).add(BigInteger.ONE);
|
||||
}
|
||||
|
||||
addValue(store, version, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int delete() {
|
||||
return deleteUsing(getMainKey().getFieldsArray());
|
||||
TableField<R, ?>[] keys = getMainKey().getFieldsArray();
|
||||
|
||||
try {
|
||||
DeleteQuery<R> delete1 = create().deleteQuery(getTable());
|
||||
Util.addConditions(delete1, this, keys);
|
||||
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
|
||||
// [#1596] Add additional conditions for version and/or timestamp columns
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
addConditionForVersionAndTimestamp(delete1);
|
||||
}
|
||||
|
||||
// [#1547] Try fetching the Record again first, and compare this
|
||||
// Record's original values with the ones in the database
|
||||
else {
|
||||
checkIfChanged(keys);
|
||||
}
|
||||
}
|
||||
|
||||
int result = delete1.execute();
|
||||
checkIfChanged(result, null, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
// [#673] If store() is called after delete(), a new INSERT should
|
||||
// be executed and the record should be recreated
|
||||
finally {
|
||||
for (Field<?> field : getFields()) {
|
||||
getValue0(field).setChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void refresh() {
|
||||
refreshUsing(getMainKey().getFieldsArray());
|
||||
SimpleSelectQuery<R> select = create().selectQuery(getTable());
|
||||
Util.addConditions(select, this, getMainKey().getFieldsArray());
|
||||
|
||||
if (select.execute() == 1) {
|
||||
AbstractRecord record = (AbstractRecord) select.getResult().get(0);
|
||||
|
||||
for (Field<?> field : getFields()) {
|
||||
setValue0(field, record.getValue0(field));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new InvalidResultException("Exactly one row expected for refresh. Record does not exist in database.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
Collection<Field<?>> getReturning() {
|
||||
Collection<Field<?>> result = super.getReturning();
|
||||
private final Collection<Field<?>> getReturning() {
|
||||
Collection<Field<?>> result = new LinkedHashSet<Field<?>>();
|
||||
|
||||
Identity<R, ?> identity = getTable().getIdentity();
|
||||
if (identity != null) {
|
||||
result.add(identity.getField());
|
||||
}
|
||||
|
||||
result.addAll(getMainKey().getFields());
|
||||
return result;
|
||||
}
|
||||
@ -118,4 +362,104 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
private final <T> void setValue(Record record, Field<T> field) {
|
||||
record.setValue(field, getValue(field));
|
||||
}
|
||||
|
||||
private final boolean isExecuteWithOptimisticLocking() {
|
||||
Configuration configuration = getConfiguration();
|
||||
|
||||
// This can be null when the current record is detached
|
||||
if (configuration != null) {
|
||||
return TRUE.equals(configuration.getSettings().isExecuteWithOptimisticLocking());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private final void addConditionForVersionAndTimestamp(org.jooq.ConditionProvider query) {
|
||||
TableField<R, ?> v = getTable().getRecordVersion();
|
||||
TableField<R, ?> t = getTable().getRecordTimestamp();
|
||||
|
||||
if (v != null) Util.addCondition(query, this, v);
|
||||
if (t != null) Util.addCondition(query, this, t);
|
||||
}
|
||||
|
||||
private final boolean isTimestampOrVersionAvailable() {
|
||||
UpdatableTable<R> table = getTable();
|
||||
|
||||
return table.getRecordTimestamp() != null || table.getRecordVersion() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an additional SELECT .. FOR UPDATE to check if the underlying
|
||||
* database record has been changed compared to this record.
|
||||
*/
|
||||
private final void checkIfChanged(TableField<R, ?>[] keys) {
|
||||
SimpleSelectQuery<R> select = create().selectQuery(getTable());
|
||||
Util.addConditions(select, this, keys);
|
||||
|
||||
// [#1547] SQLite doesn't support FOR UPDATE. CUBRID and SQL Server
|
||||
// can simulate it, though!
|
||||
if (create().getDialect() != SQLDialect.SQLITE) {
|
||||
select.setForUpdate(true);
|
||||
}
|
||||
|
||||
R record = select.fetchOne();
|
||||
|
||||
if (record == null) {
|
||||
throw new DataChangedException("Database record no longer exists");
|
||||
}
|
||||
|
||||
for (Field<?> field : getFields()) {
|
||||
Value<?> thisValue = getValue0(field);
|
||||
Value<?> thatValue = ((AbstractRecord) record).getValue0(field);
|
||||
|
||||
Object thisObject = thisValue.getOriginal();
|
||||
Object thatObject = thatValue.getOriginal();
|
||||
|
||||
if (!StringUtils.equals(thisObject, thatObject)) {
|
||||
throw new DataChangedException("Database record has been changed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a database record was changed in the database.
|
||||
*/
|
||||
private final void checkIfChanged(int result, BigInteger version, Timestamp timestamp) {
|
||||
|
||||
// [#1596] If update/delete was successful, update version and/or
|
||||
// timestamp columns.
|
||||
// [#673] Do this also for deletions, in case a deleted record is re-added
|
||||
if (result > 0) {
|
||||
setRecordVersionAndTimestamp(version, timestamp);
|
||||
}
|
||||
|
||||
// [#1596] No records were updated due to version and/or timestamp change
|
||||
else if (isExecuteWithOptimisticLocking()) {
|
||||
throw new DataChangedException("Database record has been changed or doesn't exist any longer");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted method to ensure generic type safety.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private final <T> void setValue0(Field<T> field, Value<?> value) {
|
||||
setValue(field, (Value<T>) value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a generated version and timestamp value onto this record after
|
||||
* successfully storing the record.
|
||||
*/
|
||||
private final void setRecordVersionAndTimestamp(BigInteger version, Timestamp timestamp) {
|
||||
if (version != null) {
|
||||
TableField<R, ?> field = getTable().getRecordVersion();
|
||||
setValue0(field, new Value<Object>(field.getDataType().convert(version)));
|
||||
}
|
||||
if (timestamp != null) {
|
||||
TableField<R, ?> field = getTable().getRecordTimestamp();
|
||||
setValue0(field, new Value<Object>(field.getDataType().convert(timestamp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public final class UByte extends UNumber implements Comparable<UByte> {
|
||||
* parsable <code>unsigned byte</code>.
|
||||
*/
|
||||
public static UByte valueOf(String value) throws NumberFormatException {
|
||||
return valueOf(rangeCheck(Short.parseShort(value)));
|
||||
return valueOfUnchecked(rangeCheck(Short.parseShort(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,6 +105,9 @@ public final class UByte extends UNumber implements Comparable<UByte> {
|
||||
return valueOfUnchecked((short) (value & MAX_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a short without checking the value.
|
||||
*/
|
||||
private static UByte valueOfUnchecked(short value) throws NumberFormatException {
|
||||
return VALUES[value & MAX_VALUE];
|
||||
}
|
||||
@ -144,11 +147,8 @@ public final class UByte extends UNumber implements Comparable<UByte> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> is not in the range
|
||||
* of an <code>unsigned byte</code>
|
||||
* @deprecated - Use {@link #valueOf(long)}, or {@link Unsigned#ubyte(long)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UByte(long value) throws NumberFormatException {
|
||||
private UByte(long value) throws NumberFormatException {
|
||||
this.value = rangeCheck(value);
|
||||
}
|
||||
|
||||
@ -157,11 +157,8 @@ public final class UByte extends UNumber implements Comparable<UByte> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> is not in the range
|
||||
* of an <code>unsigned byte</code>
|
||||
* @deprecated - Use {@link #valueOf(int)}, or {@link Unsigned#ubyte(int)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UByte(int value) throws NumberFormatException {
|
||||
private UByte(int value) throws NumberFormatException {
|
||||
this.value = rangeCheck(value);
|
||||
}
|
||||
|
||||
@ -170,23 +167,16 @@ public final class UByte extends UNumber implements Comparable<UByte> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> is not in the range
|
||||
* of an <code>unsigned byte</code>
|
||||
* @deprecated - Use {@link #valueOf(short)}, or
|
||||
* {@link Unsigned#ubyte(short)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UByte(short value) throws NumberFormatException {
|
||||
private UByte(short value) throws NumberFormatException {
|
||||
this.value = rangeCheck(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>unsigned byte</code> by masking it with <code>0xFF</code>
|
||||
* i.e. <code>(byte) -1</code> becomes <code>(ubyte) 255</code>
|
||||
*
|
||||
* @deprecated - Use {@link #valueOf(byte)}, or {@link Unsigned#ubyte(byte)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UByte(byte value) {
|
||||
private UByte(byte value) {
|
||||
this.value = (short) (value & MAX_VALUE);
|
||||
}
|
||||
|
||||
@ -195,11 +185,8 @@ public final class UByte extends UNumber implements Comparable<UByte> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> does not contain a
|
||||
* parsable <code>unsigned byte</code>.
|
||||
* @deprecated - Use {@link #valueOf(String)}, or
|
||||
* {@link Unsigned#ubyte(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UByte(String value) throws NumberFormatException {
|
||||
private UByte(String value) throws NumberFormatException {
|
||||
this.value = rangeCheck(Short.parseShort(value));
|
||||
}
|
||||
|
||||
|
||||
@ -35,34 +35,154 @@
|
||||
*/
|
||||
package org.jooq.tools.unsigned;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
* The <code>unsigned int</code> type
|
||||
*
|
||||
* @author Lukas Eder
|
||||
* @author Ed Schaller
|
||||
*/
|
||||
public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
private static final Class<UInteger> CLASS = UInteger.class;
|
||||
private static final String CLASS_NAME = CLASS.getName();
|
||||
|
||||
/**
|
||||
* System property name for the property to set the size of the pre-cache.
|
||||
*/
|
||||
private static final String PRECACHE_PROPERTY = CLASS_NAME + ".precacheSize";
|
||||
|
||||
/**
|
||||
* Default size for the value cache.
|
||||
*/
|
||||
private static final int DEFAULT_PRECACHE_SIZE = 256;
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -6821055240959745390L;
|
||||
private static final long serialVersionUID = -6821055240959745390L;
|
||||
|
||||
/**
|
||||
* Cached values
|
||||
*/
|
||||
private static final UInteger[] VALUES = mkValues();
|
||||
|
||||
/**
|
||||
* A constant holding the minimum value an <code>unsigned int</code> can
|
||||
* have, 0.
|
||||
*/
|
||||
public static final long MIN_VALUE = 0x00000000;
|
||||
public static final long MIN_VALUE = 0x00000000;
|
||||
|
||||
/**
|
||||
* A constant holding the maximum value an <code>unsigned int</code> can
|
||||
* have, 2<sup>32</sup>-1.
|
||||
*/
|
||||
public static final long MAX_VALUE = 0xffffffffL;
|
||||
public static final long MAX_VALUE = 0xffffffffL;
|
||||
|
||||
/**
|
||||
* The value modelling the content of this <code>unsigned int</code>
|
||||
*/
|
||||
private final long value;
|
||||
private final long value;
|
||||
|
||||
/**
|
||||
* Figure out the size of the precache.
|
||||
*
|
||||
* @return The parsed value of the system property
|
||||
* {@link #PRECACHE_PROPERTY} or {@link #DEFAULT_PRECACHE_SIZE} if
|
||||
* the property is not set, not a number or retrieving results in a
|
||||
* {@link SecurityException}. If the parsed value is zero or
|
||||
* negative no cache will be created. If the value is larger than
|
||||
* {@link Integer#MAX_VALUE} then Integer#MAX_VALUE will be used.
|
||||
*/
|
||||
private static final int getPrecacheSize() {
|
||||
String prop = null;
|
||||
long propParsed;
|
||||
|
||||
try {
|
||||
prop = System.getProperty(PRECACHE_PROPERTY);
|
||||
}
|
||||
catch (SecurityException e) {
|
||||
// security manager stopped us so use default
|
||||
// FIXME: should we log this somewhere?
|
||||
return DEFAULT_PRECACHE_SIZE;
|
||||
}
|
||||
if (prop == null)
|
||||
return DEFAULT_PRECACHE_SIZE;
|
||||
if (prop.length() <= 0) {
|
||||
// empty value
|
||||
// FIXME: should we log this somewhere?
|
||||
return DEFAULT_PRECACHE_SIZE;
|
||||
}
|
||||
try {
|
||||
propParsed = Long.parseLong(prop);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// not a valid number
|
||||
// FIXME: should we log this somewhere?
|
||||
return DEFAULT_PRECACHE_SIZE;
|
||||
}
|
||||
// treat negative value as no cache...
|
||||
if (propParsed < 0)
|
||||
return 0;
|
||||
if (propParsed > Integer.MAX_VALUE) {
|
||||
// FIXME: should we log this somewhere
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
return (int) propParsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a cached value for initial unsigned integer values.
|
||||
*
|
||||
* @return Array of cached values for UInteger
|
||||
*/
|
||||
private static final UInteger[] mkValues() {
|
||||
int precacheSize = getPrecacheSize();
|
||||
UInteger[] ret;
|
||||
|
||||
if (precacheSize <= 0)
|
||||
return null;
|
||||
ret = new UInteger[precacheSize];
|
||||
for (int i = 0; i < precacheSize; i++)
|
||||
ret[i] = new UInteger(i);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unchecked internal constructor. This serves two purposes: first it allows
|
||||
* {@link #UInteger(long)} to stay deprecated without warnings and second
|
||||
* constructor without unnecessary value checks.
|
||||
*
|
||||
* @param value The value to wrap
|
||||
* @param unused Unused paramater to distinguish between this and the
|
||||
* deprecated public constructor.
|
||||
*/
|
||||
private UInteger(long value, boolean unused) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a cached value.
|
||||
*
|
||||
* @param value Cached value to retrieve
|
||||
* @return Cached value if one exists. Null otherwise.
|
||||
*/
|
||||
private static UInteger getCached(long value) {
|
||||
if (VALUES != null && value < VALUES.length)
|
||||
return VALUES[(int) value];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a long without checking the value.
|
||||
*/
|
||||
private static UInteger valueOfUnchecked(long value) {
|
||||
UInteger cached;
|
||||
|
||||
if ((cached = getCached(value)) != null)
|
||||
return cached;
|
||||
return new UInteger(value, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>unsigned int</code>
|
||||
@ -71,7 +191,7 @@ public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
* parsable <code>unsigned int</code>.
|
||||
*/
|
||||
public static UInteger valueOf(String value) throws NumberFormatException {
|
||||
return new UInteger(value);
|
||||
return valueOfUnchecked(rangeCheck(Long.parseLong(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +200,7 @@ public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
* <code>(uint) 4294967295</code>
|
||||
*/
|
||||
public static UInteger valueOf(int value) {
|
||||
return new UInteger(value);
|
||||
return valueOfUnchecked(value & MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +210,7 @@ public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
* of an <code>unsigned byte</code>
|
||||
*/
|
||||
public static UInteger valueOf(long value) throws NumberFormatException {
|
||||
return new UInteger(value);
|
||||
return valueOfUnchecked(rangeCheck(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,25 +218,17 @@ public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> is not in the range
|
||||
* of an <code>unsigned int</code>
|
||||
* @deprecated - Use {@link #valueOf(long)}, or {@link Unsigned#uint(long)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UInteger(long value) throws NumberFormatException {
|
||||
this.value = value;
|
||||
rangeCheck();
|
||||
private UInteger(long value) throws NumberFormatException {
|
||||
this.value = rangeCheck(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an <code>unsigned int</code> by masking it with
|
||||
* <code>0xFFFFFFFF</code> i.e. <code>(int) -1</code> becomes
|
||||
* <code>(uint) 4294967295</code>
|
||||
*
|
||||
* @deprecated - Use {@link #valueOf(int)}, or {@link Unsigned#uint(int)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UInteger(int value) {
|
||||
private UInteger(int value) {
|
||||
this.value = value & MAX_VALUE;
|
||||
}
|
||||
|
||||
@ -125,19 +237,40 @@ public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> does not contain a
|
||||
* parsable <code>unsigned int</code>.
|
||||
* @deprecated - Use {@link #valueOf(String)}, or
|
||||
* {@link Unsigned#uint(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UInteger(String value) throws NumberFormatException {
|
||||
this.value = Long.parseLong(value);
|
||||
rangeCheck();
|
||||
private UInteger(String value) throws NumberFormatException {
|
||||
this.value = rangeCheck(Long.parseLong(value));
|
||||
}
|
||||
|
||||
private void rangeCheck() throws NumberFormatException {
|
||||
/**
|
||||
* Throw exception if value out of range (long version)
|
||||
*
|
||||
* @param value Value to check
|
||||
* @return value if it is in range
|
||||
* @throws NumberFormatException if value is out of range
|
||||
*/
|
||||
private static long rangeCheck(long value) throws NumberFormatException {
|
||||
if (value < MIN_VALUE || value > MAX_VALUE) {
|
||||
throw new NumberFormatException("Value is out of range : " + value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace version read through deserialization with cached version.
|
||||
*
|
||||
* @return cached instance of this object's value if one exists, otherwise
|
||||
* this object
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
UInteger cached;
|
||||
|
||||
// the value read could be invalid so check it
|
||||
rangeCheck(value);
|
||||
if ((cached = getCached(value)) != null)
|
||||
return cached;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -167,6 +300,8 @@ public final class UInteger extends UNumber implements Comparable<UInteger> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj instanceof UInteger) {
|
||||
return value == ((UInteger) obj).value;
|
||||
}
|
||||
|
||||
@ -106,11 +106,8 @@ public final class ULong extends UNumber implements Comparable<ULong> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> is not in the range
|
||||
* of an <code>unsigned long</code>
|
||||
* @deprecated - Use {@link #valueOf(BigInteger)}, or
|
||||
* {@link Unsigned#ulong(BigInteger)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public ULong(BigInteger value) throws NumberFormatException {
|
||||
private ULong(BigInteger value) throws NumberFormatException {
|
||||
this.value = value;
|
||||
rangeCheck();
|
||||
}
|
||||
@ -119,12 +116,8 @@ public final class ULong extends UNumber implements Comparable<ULong> {
|
||||
* Create an <code>unsigned long</code> by masking it with
|
||||
* <code>0xFFFFFFFFFFFFFFFF</code> i.e. <code>(long) -1</code> becomes
|
||||
* <code>(uint) 18446744073709551615</code>
|
||||
*
|
||||
* @deprecated - Use {@link #valueOf(long)}, or {@link Unsigned#ulong(long)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public ULong(long value) {
|
||||
private ULong(long value) {
|
||||
if (value >= 0) {
|
||||
this.value = BigInteger.valueOf(value);
|
||||
}
|
||||
@ -138,11 +131,8 @@ public final class ULong extends UNumber implements Comparable<ULong> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> does not contain a
|
||||
* parsable <code>unsigned long</code>.
|
||||
* @deprecated - Use {@link #valueOf(String)}, or
|
||||
* {@link Unsigned#ulong(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public ULong(String value) throws NumberFormatException {
|
||||
private ULong(String value) throws NumberFormatException {
|
||||
this.value = new BigInteger(value);
|
||||
rangeCheck();
|
||||
}
|
||||
|
||||
@ -98,11 +98,8 @@ public final class UShort extends UNumber implements Comparable<UShort> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> is not in the range
|
||||
* of an <code>unsigned short</code>
|
||||
* @deprecated - Use {@link #valueOf(int)}, or {@link Unsigned#ushort(int)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UShort(int value) throws NumberFormatException {
|
||||
private UShort(int value) throws NumberFormatException {
|
||||
this.value = value;
|
||||
rangeCheck();
|
||||
}
|
||||
@ -111,12 +108,8 @@ public final class UShort extends UNumber implements Comparable<UShort> {
|
||||
* Create an <code>unsigned short</code> by masking it with
|
||||
* <code>0xFFFF</code> i.e. <code>(short) -1</code> becomes
|
||||
* <code>(ushort) 65535</code>
|
||||
*
|
||||
* @deprecated - Use {@link #valueOf(short)}, or
|
||||
* {@link Unsigned#ushort(short)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UShort(short value) {
|
||||
private UShort(short value) {
|
||||
this.value = value & MAX_VALUE;
|
||||
}
|
||||
|
||||
@ -125,11 +118,8 @@ public final class UShort extends UNumber implements Comparable<UShort> {
|
||||
*
|
||||
* @throws NumberFormatException If <code>value</code> does not contain a
|
||||
* parsable <code>unsigned short</code>.
|
||||
* @deprecated - Use {@link #valueOf(String)}, or
|
||||
* {@link Unsigned#ushort(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public UShort(String value) throws NumberFormatException {
|
||||
private UShort(String value) throws NumberFormatException {
|
||||
this.value = Integer.parseInt(value);
|
||||
rangeCheck();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user