/** * Set the current source file of the given metadata. */ protected void setSourceFile(SequenceMetaData meta, File sourceFile) { meta.setSource(sourceFile, meta.getSourceScope(), meta.getSourceType()); }
/** * Return the current source file of the given metadata. */ protected File getSourceFile(SequenceMetaData meta) { return meta.getSourceFile(); }
/** * Add standard properties to the given properties buffer. */ protected void addStandardProperties(StringBuilder props) { appendProperty(props, PROP_SEQUENCE, wrapValue(_sequence)); appendProperty(props, PROP_INITIAL_VALUE, _initial); appendProperty(props, PROP_ALLOCATE, _allocate); appendProperty(props, PROP_INCREMENT, _increment); appendProperty(props, PROP_SCHEMA, wrapValue(_schema)); appendProperty(props, PROP_CATALOG, wrapValue(_catalog)); }
meta.setSequencePlugin(Configurations.getPlugin(clsName, props)); meta.setSequence(seq); meta.setInitialValue(initial); meta.setAllocate(allocate); meta.setSchema(schema); meta.setCatalog(catalog); meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML); Locator locator = getLocation().getLocator(); if (locator != null) { meta.setLineNumber(locator.getLineNumber()); meta.setColNumber(locator.getColumnNumber());
meta.setSequencePlugin(Configurations.getPlugin(clsName, props)); meta.setSequence(seq); meta.setInitialValue(initial); meta.setAllocate(allocate); meta.setSchema(schema); meta.setCatalog(catalog); meta.setSource(getSourceFile(), (el instanceof Class) ? el : null, SourceTracker.SRC_ANNOTATIONS);
Log log = getLog(); if (log.isInfoEnabled()) log.info(_loc.get("ser-sequence", meta.getName())); ab.add("name", meta.getName()); String plugin = meta.getSequencePlugin(); String clsName = Configurations.getClassName(plugin); String props = Configurations.getProperties(plugin); (plugin)) ab.add("sequenceName", plugin); if (meta.getInitialValue() != 0 && meta.getInitialValue() != -1) ab.add("initialValue", meta.getInitialValue()); if (meta.getAllocate() != 50 && meta.getAllocate() != -1) ab.add("allocationSize", meta.getAllocate()); if (meta.getSchema() != null) ab.add("schema", meta.getSchema()); if (meta.getCatalog() != null) ab.add("catalog", meta.getCatalog());
if (!_annos && meta.getSourceType() == meta.SRC_ANNOTATIONS) return; log.info(_loc.get("ser-sequence", meta.getName())); addAttribute("name", meta.getName()); String plugin = meta.getSequencePlugin(); String clsName = Configurations.getClassName(plugin); String props = Configurations.getProperties(plugin); (plugin)) addAttribute("sequence-name", plugin); if (meta.getInitialValue() != 0 && meta.getInitialValue() != -1) addAttribute("initial-value", String.valueOf(meta.getInitialValue())); if (meta.getAllocate() != 50 && meta.getAllocate() != -1) addAttribute("allocation-size", String.valueOf(meta.getAllocate()));
meta.setSequencePlugin(Configurations.getPlugin(clsName, props)); meta.setSequence(seq); meta.setInitialValue(initial); meta.setAllocate(allocate); meta.setSource(getSourceFile(), scope, meta.SRC_XML); return true;
public Generator getNamedGenerator(String name) { assertNotCloseInvoked(); try { SequenceMetaData meta = _broker.getConfiguration(). getMetaDataRepositoryInstance().getSequenceMetaData(name, _broker.getClassLoader(), true); Seq seq = meta.getInstance(_broker.getClassLoader()); return new GeneratorImpl(seq, name, _broker, null); } catch (RuntimeException re) { throw PersistenceExceptions.toPersistenceException(re); } }
throws SAXException { if (!getSerializeAnnotations() && meta.getSourceType() == meta.SRC_ANNOTATIONS) return; if (SequenceMapping.IMPL_VALUE_TABLE.equals(meta.getSequencePlugin())) { super.serializeSequence(meta); return;
PluginValue plugin = newPluginValue("sequence-plugin"); plugin.setString(_plugin); String clsName = plugin.getClassName(); if (plugin.getProperties() != null) props.append(plugin.getProperties()); addStandardProperties(props);
public Object getSourceScope() { return _seqs[0].getSourceScope(); }
public int getSourceType() { return _seqs[0].getSourceType(); }
protected void addStandardProperties(StringBuffer props) { super.addStandardProperties(props); appendProperty(props, PROP_TABLE, _table); appendProperty(props, PROP_SEQUENCE_COL, _sequenceColumn); appendProperty(props, PROP_PK_COL, _primaryKeyColumn); appendProperty(props, PROP_PK_VALUE, _primaryKeyValue); } }
@Override protected void serializeSequence(SequenceMetaData meta) { if (SequenceMapping.IMPL_VALUE_TABLE.equals(meta.getSequencePlugin())) { super.serializeSequence(meta); return; } AnnotationBuilder abTblGen = addAnnotation(TableGenerator.class, meta); SequenceMapping seq = (SequenceMapping) meta; abTblGen.add("name", seq.getName()); String table = seq.getTable(); if (table != null) { int dotIdx = table.indexOf('.'); if (dotIdx == -1) abTblGen.add("table", table); else { abTblGen.add("table", table.substring(dotIdx + 1)); abTblGen.add("schema", table.substring(0, dotIdx)); } } if (!StringUtils.isEmpty(seq.getPrimaryKeyColumn())) abTblGen.add("pkColumnName", seq.getPrimaryKeyColumn()); if (!StringUtils.isEmpty(seq.getSequenceColumn())) abTblGen.add("valueColumnName", seq.getSequenceColumn()); if (!StringUtils.isEmpty(seq.getPrimaryKeyValue())) abTblGen.add("pkColumnValue", seq.getPrimaryKeyValue()); if (seq.getAllocate() != 50 && seq.getAllocate() != -1) abTblGen.add("allocationSize", seq.getAllocate() + ""); if (seq.getInitialValue() != 0 && seq.getInitialValue() != -1) abTblGen.add("initialValue", seq.getInitialValue() + ""); }
/** * Create a new sequence metadata instance. */ protected SequenceMetaData newSequenceMetaData(String name) { return new SequenceMetaData(name, this); }
/** * Add standard properties to the given properties buffer. */ protected void addStandardProperties(StringBuffer props) { appendProperty(props, PROP_SEQUENCE, _sequence); appendProperty(props, PROP_INITIAL_VALUE, _initial); appendProperty(props, PROP_ALLOCATE, _allocate); appendProperty(props, PROP_INCREMENT, _increment); }
meta.setSequencePlugin(Configurations.getPlugin(clsName, props)); meta.setSequence(seq); meta.setInitialValue(initial); meta.setAllocate(allocate); meta.setSchema(schema); meta.setCatalog(catalog); meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML); Locator locator = getLocation().getLocator(); if (locator != null) { meta.setLineNumber(locator.getLineNumber()); meta.setColNumber(locator.getColumnNumber());
meta.setSequencePlugin(Configurations.getPlugin(clsName, props)); meta.setSequence(seq); meta.setInitialValue(initial); meta.setAllocate(allocate); meta.setSchema(schema); meta.setCatalog(catalog); meta.setSource(getSourceFile(), (el instanceof Class) ? el : null, SourceTracker.SRC_ANNOTATIONS);