/** * Render the DB type for this property given the strict mode. */ public String getColumnDefn(BeanProperty p, boolean strict) { DbPlatformType dbType = getDbType(p); if (dbType == null) { throw new IllegalStateException("Unknown DbType mapping for " + p.getFullBeanName()); } return p.renderDbType(dbType, strict); }
versionProperty = prop; } else { logger.warn("Multiple @Version properties - property " + prop.getFullBeanName() + " not treated as a version property");
public void jsonRead(SpiJsonReader ctx, EntityBean bean) throws IOException { JsonToken event = ctx.nextToken(); if (JsonToken.VALUE_NULL == event) { if (jsonDeserialize) { setValue(bean, null); } } else { // expect to read non-null json value Object objValue; if (scalarType != null) { objValue = scalarType.jsonRead(ctx.getParser()); } else { try { objValue = ctx.readValueUsingObjectMapper(propertyType); } catch (IOException e) { // change in behavior for #318 objValue = null; String msg = "Error trying to use Jackson ObjectMapper to read transient property " + getFullBeanName() + " - consider marking this property with @JsonIgnore"; logger.error(msg, e); } } if (jsonDeserialize) { setValue(bean, objValue); } } }
private DbPlatformType getDbType(BeanProperty p) { if (p.isDbEncrypted()) { return dbTypeMap.get(p.getDbEncryptedType()); } if (p.isLocalEncrypted()) { // scalar type potentially wrapping varbinary db type ScalarType<Object> scalarType = p.getScalarType(); int jdbcType = scalarType.getJdbcType(); return dbTypeMap.get(jdbcType); } // can be the logical JSON types (JSON, JSONB, JSONClob, JSONBlob, JSONVarchar) int dbType = p.getDbType(platformTypes); if (dbType == 0) { throw new RuntimeException("No scalarType defined for " + p.getFullBeanName()); } return dbTypeMap.get(dbType); }
public Object load(BeanProperty prop) { if (!rawSql && !prop.isLoadProperty(ctx.isDraftQuery())) { return null; } if ((bean == null) || (lazyLoading && ebi.isLoadedProperty(prop.getPropertyIndex())) || (type != null && !prop.isAssignableFrom(type))) { // ignore this property // ... null: bean already in persistence context // ... lazyLoading: partial bean that is lazy loading // ... type: inheritance and not assignable to this instance prop.loadIgnore(ctx); return null; } try { Object dbVal = prop.read(ctx); if (!refreshLoading) { prop.setValue(bean, dbVal); } else { prop.setValueIntercept(bean, dbVal); } return dbVal; } catch (Exception e) { bean._ebean_getIntercept().setLoadError(prop.getPropertyIndex(), e); ctx.handleLoadError(prop.getFullBeanName(), e); return prop.getValue(bean); } }
/** * Render the DB type for this property given the strict mode. */ public String getColumnDefn(BeanProperty p, boolean strict) { DbPlatformType dbType = getDbType(p); if (dbType == null) { throw new IllegalStateException("Unknown DbType mapping for " + p.getFullBeanName()); } return p.renderDbType(dbType, strict); }
versionProperty = prop; } else { logger.warn("Multiple @Version properties - property " + prop.getFullBeanName() + " not treated as a version property");
public void jsonRead(SpiJsonReader ctx, EntityBean bean) throws IOException { JsonToken event = ctx.nextToken(); if (JsonToken.VALUE_NULL == event) { if (jsonDeserialize) { setValue(bean, null); } } else { // expect to read non-null json value Object objValue; if (scalarType != null) { objValue = scalarType.jsonRead(ctx.getParser()); } else { try { objValue = ctx.readValueUsingObjectMapper(propertyType); } catch (IOException e) { // change in behavior for #318 objValue = null; String msg = "Error trying to use Jackson ObjectMapper to read transient property " + getFullBeanName() + " - consider marking this property with @JsonIgnore"; logger.error(msg, e); } } if (jsonDeserialize) { setValue(bean, objValue); } } }
private DbPlatformType getDbType(BeanProperty p) { if (p.isDbEncrypted()) { return dbTypeMap.get(p.getDbEncryptedType()); } if (p.isLocalEncrypted()) { // scalar type potentially wrapping varbinary db type ScalarType<Object> scalarType = p.getScalarType(); int jdbcType = scalarType.getJdbcType(); return dbTypeMap.get(jdbcType); } // can be the logical JSON types (JSON, JSONB, JSONClob, JSONBlob, JSONVarchar) int dbType = p.getDbType(platformTypes); if (dbType == 0) { throw new RuntimeException("No scalarType defined for " + p.getFullBeanName()); } return dbTypeMap.get(dbType); }
public Object load(BeanProperty prop) { if (!rawSql && !prop.isLoadProperty(ctx.isDraftQuery())) { return null; } if ((bean == null) || (lazyLoading && ebi.isLoadedProperty(prop.getPropertyIndex())) || (type != null && !prop.isAssignableFrom(type))) { // ignore this property // ... null: bean already in persistence context // ... lazyLoading: partial bean that is lazy loading // ... type: inheritance and not assignable to this instance prop.loadIgnore(ctx); return null; } try { Object dbVal = prop.read(ctx); if (!refreshLoading) { prop.setValue(bean, dbVal); } else { prop.setValueIntercept(bean, dbVal); } return dbVal; } catch (Exception e) { bean._ebean_getIntercept().setLoadError(prop.getPropertyIndex(), e); ctx.handleLoadError(prop.getFullBeanName(), e); return prop.getValue(bean); } }