Java Code Examples for com.j256.ormlite.field.FieldType#extractJavaFieldValue()
The following examples show how to use
com.j256.ormlite.field.FieldType#extractJavaFieldValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseArgumentHolder.java From ormlite-core with ISC License | 6 votes |
@Override public Object getSqlArgValue() throws SQLException { if (!isValueSet()) { throw new SQLException("Column value has not been set for " + columnName); } Object value = getValue(); if (value == null) { return null; } else if (fieldType == null) { return value; } else if (fieldType.isForeign() && fieldType.getType() == value.getClass()) { FieldType refFieldType = fieldType.getForeignRefField(); return refFieldType.extractJavaFieldValue(value); } else { return fieldType.convertJavaFieldToSqlArgValue(value); } }
Example 2
Source File: MappedCreate.java From ormlite-core with ISC License | 5 votes |
private boolean foreignCollectionsAreAssigned(FieldType[] foreignCollections, Object data) throws SQLException { for (FieldType fieldType : foreignCollections) { if (fieldType.extractJavaFieldValue(data) == null) { return false; } } return true; }
Example 3
Source File: BaseDaoImpl.java From ormlite-core with ISC License | 5 votes |
@Override public boolean objectsEqual(T data1, T data2) throws SQLException { checkForInitialized(); for (FieldType fieldType : tableInfo.getFieldTypes()) { Object fieldObj1 = fieldType.extractJavaFieldValue(data1); Object fieldObj2 = fieldType.extractJavaFieldValue(data2); // we can't just do fieldObj1.equals(fieldObj2) because of byte[].equals() if (!fieldType.getDataPersister().dataIsEqual(fieldObj1, fieldObj2)) { return false; } } return true; }
Example 4
Source File: BaseDaoImpl.java From ormlite-core with ISC License | 5 votes |
@Override public ID extractId(T data) throws SQLException { checkForInitialized(); FieldType idField = tableInfo.getIdField(); if (idField == null) { throw new SQLException("Class " + dataClass + " does not have an id field"); } @SuppressWarnings("unchecked") ID id = (ID) idField.extractJavaFieldValue(data); return id; }