public void initialize() { DBDictionary dict = field.getMappingRepository().getDBDictionary(); _maxSize = dict.maxEmbeddedBlobSize; field.setUsesImplData(Boolean.TRUE); }
/** * Determine the default strategy to use for the given discriminator. * Does not take into account the current strategy, if any. */ protected DiscriminatorStrategy defaultStrategy(Discriminator discrim) { return defaultStrategy(discrim, getStrategyInstaller().isAdapting()); }
/** * Determine the default handler to use for the given value. Does * not take into account the named handler, if any. */ protected ValueHandler defaultHandler(ValueMapping val) { return defaultHandler(val, getStrategyInstaller().isAdapting()); }
public void installStrategy(FieldMapping field) { FieldStrategy strategy = repos.namedStrategy(field, true); if (strategy == null) strategy = repos.defaultStrategy(field, true, true); field.setStrategy(strategy, Boolean.TRUE); }
ValueHandler handler = namedHandler(field); if (handler != null) { if (installHandlers) handler = defaultHandler(field, adapting); if (handler != null) { if (installHandlers) Object strat = mappedStrategy(field, field.getType(), adapting); if (strat instanceof FieldStrategy) return (FieldStrategy) strat; || field.getType() == Byte[].class)) { if (_dict.maxEmbeddedBlobSize != -1) { handler = defaultHandler(field, adapting); if (handler != null) { if (installHandlers) && (field.getType() == char[].class || field.getType() == Character[].class)) { if (_dict.maxEmbeddedClobSize != -1 && isClob(field, false)) { handler = defaultHandler(field, adapting); if (handler != null) { if (installHandlers) FieldStrategy strat = defaultTypeStrategy(field, installHandlers, adapting); if (strat != null) { handler = defaultHandler(field, adapting);
return new PrimitiveFieldStrategy(); case JavaTypes.STRING: if (!isClob(field, false)) return new StringFieldStrategy(); if (_dict.maxEmbeddedClobSize != -1) return new EmbedFieldStrategy(); if (field.getTypeMapping().isMapped() || !useUntypedPCHandler(field)) return new RelationFieldStrategy(); break; case JavaTypes.COLLECTION: ValueMapping elem = field.getElementMapping(); ValueHandler ehandler = namedHandler(elem); if (ehandler == null) ehandler = defaultHandler(elem); if (ehandler != null) return handlerCollectionStrategy(field, ehandler, installHandlers); if (elem.getTypeCode() == JavaTypes.PC && !elem.isSerialized() && !elem.isEmbeddedPC()) { if (useInverseKeyMapping(field)) return new RelationCollectionInverseKeyFieldStrategy(); return new RelationCollectionTableFieldStrategy(); case JavaTypes.MAP: ValueMapping key = field.getKeyMapping(); ValueHandler khandler = namedHandler(key);
/** * Create a metadata for the given instance. */ private void addMeta(Class<?> cls) { if (cls == null) return; _flush = true; MappingRepository repos = getRepository(); repos.setResolve(MODE_MAPPING, false); MetaDataFactory factory = repos.getMetaDataFactory(); factory.getDefaults().setIgnoreNonPersistent(false); factory.setStoreMode(MetaDataFactory.STORE_VERBOSE); ClassMetaData meta = repos.addMetaData(cls); FieldMetaData[] fmds = meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (fmds[i].getDeclaredTypeCode() == JavaTypes.OBJECT && fmds[i].getDeclaredType() != Object.class) fmds[i].setDeclaredTypeCode(JavaTypes.PC); } meta.setSource(_file, meta.getSourceType(), _file == null ? "": _file.getPath() ); meta.setResolve(MODE_META, true); }
public void installStrategy(Version version) { VersionStrategy strat = repos.namedStrategy(version); if (strat == null) strat = repos.defaultStrategy(version, true); try { version.setStrategy(strat, Boolean.TRUE); } catch (MetaDataException mde) { // if this is a custom strategy, don't attempt to override if (isCustomStrategy(strat)) throw mde; repos.getLog().warn(_loc.get("fatal-change", version, mde.getMessage())); version.clearMapping(); version.setStrategy(repos.defaultStrategy(version, true), Boolean.TRUE); } }
/** * Representation of the database schema. */ public synchronized SchemaGroup getSchemaGroup() { if (_schema == null) _schema = ((JDBCConfiguration) getConfiguration()). getSchemaFactoryInstance().readSchema(); return _schema; }
/** * Candidate mapping. */ public ClassMapping getCandidateTypeMapping() { if (_candidateMap == null) _candidateMap = _repos.getMapping(_candidate, null, true); return _candidateMap; }
public String get(Schema schema) { // delay this so that we don't do schema reflection for unique // table name unless necessary return cls.getMappingRepository().getMappingDefaults(). getTableName(cls, schema); } public DBIdentifier getIdentifier(Schema schema) {
/** * Constructor. Supply owning mapping. */ public ValueMappingImpl(FieldMapping owner) { super(owner); _info = owner.getMappingRepository().newMappingInfo(this); _info.setUseClassCriteria(owner.getMappingRepository(). getMappingDefaults().useClassCriteria()); }
/** * Return the mapping for the given type, or null if the type is * persistence-aware. */ private static ClassMapping getMapping(MappingRepository repos, Class<?> cls, boolean validate) { // this will parse all possible metadata rsrcs looking for cls, so // will detect if p-aware ClassMapping mapping = repos.getMapping(cls, null, false); if (mapping != null) return mapping; if (!validate || cls.isInterface() || repos.getPersistenceAware(cls) != null) return null; throw new MetaDataException(_loc.get("no-meta", cls, cls.getClassLoader())); }
public boolean isNonDefaultMappingAllowed() { OpenJPAConfiguration conf = getConfiguration(); return getMetaDataFactory().getDefaults().isNonDefaultMappingAllowed(conf); }
/** * Create a new class to be mapped to a table. The class will start out * with a default application identity class set. */ public ClassMapping newClassMapping(Class cls, Table table) { ClassMapping mapping = (ClassMapping) getRepository().addMetaData(cls); Class sup = mapping.getDescribedType().getSuperclass(); if (sup == Object.class) setObjectIdType(mapping); else mapping.setPCSuperclass(sup); mapping.setTable(table); if (_detachable) mapping.setDetachable(true); _tables.put(table, mapping); return mapping; }
defaultHandler(val); if (def == null || val.getHandler().getClass() != def.getClass()) setStrategy(val.getHandler().getClass().getName());
@Override protected XMLPersistenceMetaDataParser newXMLParser(boolean loading) { XMLPersistenceMappingParser parser = new XMLPersistenceMappingParser ((JDBCConfiguration) repos.getConfiguration()); // strict mode means we're using a separate mapping parser, so if // we're adapting parse metadata hints if (strict && loading) parser.setMappingOverride(((MappingRepository) repos). getStrategyInstaller().isAdapting()); return parser; }
ValueHandler handler = namedHandler(field); if (handler != null) { if (installHandlers) handler = defaultHandler(field, adapting); if (handler != null) { if (installHandlers) Object strat = mappedStrategy(field, field.getType(), adapting); if (strat instanceof FieldStrategy) return (FieldStrategy) strat; || field.getType() == Byte[].class)) { if (_dict.maxEmbeddedBlobSize != -1) { handler = defaultHandler(field, adapting); if (handler != null) { if (installHandlers) && (field.getType() == char[].class || field.getType() == Character[].class)) { if (_dict.maxEmbeddedClobSize != -1 && isClob(field, false)) { handler = defaultHandler(field, adapting); if (handler != null) { if (installHandlers) FieldStrategy strat = defaultTypeStrategy(field, installHandlers, adapting); if (strat != null) { handler = defaultHandler(field, adapting);
/** * Create a metadata for the given instance. */ private void addMeta(Class<?> cls) { if (cls == null) return; _flush = true; MappingRepository repos = getRepository(); repos.setResolve(MODE_MAPPING, false); MetaDataFactory factory = repos.getMetaDataFactory(); factory.getDefaults().setIgnoreNonPersistent(false); factory.setStoreMode(MetaDataFactory.STORE_VERBOSE); ClassMetaData meta = repos.addMetaData(cls); FieldMetaData[] fmds = meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (fmds[i].getDeclaredTypeCode() == JavaTypes.OBJECT && fmds[i].getDeclaredType() != Object.class) fmds[i].setDeclaredTypeCode(JavaTypes.PC); } meta.setSource(_file, meta.getSourceType(), _file == null ? "": _file.getPath() ); meta.setResolve(MODE_META, true); }