gpt4 book ai didi

org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 06:39:40 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer类的一些代码示例,展示了XMLPersistenceMetaDataSerializer类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLPersistenceMetaDataSerializer类的具体详情如下:
包路径:org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer
类名称:XMLPersistenceMetaDataSerializer

XMLPersistenceMetaDataSerializer介绍

[英]Serializes persistence metadata back to XML. This class processes all object level tags that are store-agnostic. However, it provides hooks for the subclasses to include store-specific tags to be serialized both at <entity-mappings> and <entity> level.
[中]将持久性元数据序列化回XML。此类处理所有与存储无关的对象级标记。然而,它为子类提供了钩子,使其包含要在<entity mappings>和<entity>级别序列化的存储特定标记。

代码示例

代码示例来源:origin: org.apache.openejb.patch/openjpa

@Override
protected int type(Object o) {
  int type = super.type(o);
  if (type == -1 && o instanceof QueryResultMapping)
    return TYPE_RESULTMAP;
  return type;
}

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

/**
 * Create a new serializer
 */
protected XMLPersistenceMetaDataSerializer newXMLSerializer() {
  return new XMLPersistenceMetaDataSerializer(repos.getConfiguration());
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

/**
 * Serialize attribute override content.
 */
private void serializeAttributeOverrideContent(FieldMetaData fmd,
  FieldMetaData orig)
  throws SAXException {
  addAttribute("name", fmd.getName());
  startElement("attribute-override");
  serializeAttributeOverrideMappingContent(fmd, orig);
  endElement("attribute-override");
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

/**
 * Add one-to-many attributes.
 */
private void addOneToManyAttributes(FieldMetaData fmd)
  throws SAXException {
  if (fmd.isInDefaultFetchGroup())
    addAttribute("fetch", "EAGER");
  addTargetEntityAttribute(fmd);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

Log log = getLog();
if (log.isInfoEnabled())
  log.info(_loc.get("ser-class", meta));
addComments(meta);
addAttribute("class", getClassName(meta.getDescribedType().
  getName()));
if (isMetaDataMode()
  && !meta.getTypeAlias().equals(ClassUtil.getClassName(meta.
  getDescribedType())))
  addAttribute("name", meta.getTypeAlias());
String name = getEntityElementName(meta);
if (isMetaDataMode())
  addClassAttributes(meta, access);
if (isMappingMode())
  addClassMappingAttributes(meta);
startElement(name);
if (isMappingMode())
  serializeClassMappingContent(meta);
if (isMetaDataMode())
  serializeIdClass(meta);
if (isMappingMode())
  serializeInheritanceContent(meta);
if (isMappingMode()) {
  List seqs = (_seqs == null) ? null : _seqs.get

代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence

addComments(fmd);
addAttribute("name", fmd.getName());
PersistenceStrategy strat = getStrategy(fmd);
ValueMetaData cascades = null;
if (fmd.isPrimaryKey() && strat == PersistenceStrategy.EMBEDDED)
      break;
    case BASIC:
      if (isMetaDataMode())
        addBasicAttributes(fmd);
      strategy = "basic";
      break;
      break;
    case MANY_ONE:
      if (isMetaDataMode())
        addManyToOneAttributes(fmd);
      strategy = "many-to-one";
      cascades = fmd;
      break;
    case ONE_ONE:
      if (isMetaDataMode())
        addOneToOneAttributes(fmd);
      strategy = "one-to-one";
      cascades = fmd;
      break;
    case ONE_MANY:
      if (isMetaDataMode())

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

for (Iterator it = objects.iterator(); it.hasNext();) {
  meta = it.next();
  switch (type(meta)) {
    case TYPE_META:
      ClassMetaData cls = (ClassMetaData) meta;
      if (unique && getPackage() == null)
        setPackage(getPackage(meta));
      else if (unique) {
        unique = getPackage().equals(getPackage(meta));
        if (!unique)
          setPackage(null);
serializeNamespaceAttributes();
startElement("entity-mappings");
if (getPackage() != null) {
  startElement("package");
  addText(getPackage());
  endElement("package");
  int def = getConfiguration().getMetaDataRepositoryInstance().
    getMetaDataFactory().getDefaults().getDefaultAccessType();
  String access = null;
    access = "PROPERTY";
  if (access != null) {
    startElement("access");
    addText(access);
    endElement("access");

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Serialize query metadata.
 */
private void serializeQuery(QueryMetaData meta)
  throws SAXException {
  if (!_annos && meta.getSourceType() == meta.SRC_ANNOTATIONS)
    return;
  Log log = getLog();
  if (log.isInfoEnabled()) {
    if (meta.getSourceScope() instanceof Class)
      log.info(_loc.get("ser-cls-query",
        meta.getSourceScope(), meta.getName()));
    else
      log.info(_loc.get("ser-query", meta.getName()));
  }
  addComments(meta);
  addAttribute("name", meta.getName());
  addAttribute("query", meta.getQueryString());
  if (QueryLanguages.LANG_SQL.equals(meta.getLanguage())) {
    if (meta.getResultType() != null)
      addAttribute("result-class", meta.getResultType().getName());
    startElement("named-native-query");
    serializeQueryHints(meta);
    endElement("named-native-query");
  } else {
    startElement("named-query");
    serializeQueryHints(meta);
    endElement("named-query");
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Serialize namespace attributes
 */
private void serializeNamespaceAttributes()
  throws SAXException {
  addAttribute("xmlns", "http://java.sun.com/xml/ns/persistence/orm");
  addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
  addAttribute("xsi:schemaLocation",
    "http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd");
  addAttribute("version", "2.0");
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

public int compare(Object o1, Object o2) {
  FieldMetaData fmd1 = (FieldMetaData) o1;
  FieldMetaData fmd2 = (FieldMetaData) o2;
  if (fmd1.isPrimaryKey()) {
    if (fmd2.isPrimaryKey())
      return fmd1.compareTo(fmd2);
    return -1;
  }
  if (fmd2.isPrimaryKey())
    return 1;
  if (fmd1.isVersion()) {
    if (fmd2.isVersion())
      return compareListingOrder(fmd1, fmd2);
    return getStrategy(fmd2) == PersistenceStrategy.BASIC ? 1 : -1;
  }
  if (fmd2.isVersion())
    return getStrategy(fmd1) == PersistenceStrategy.BASIC ? -1 : 1;
  int stcmp = getStrategy(fmd1).compareTo(getStrategy(fmd2));
  if (stcmp != 0)
    return stcmp;
  return compareListingOrder(fmd1, fmd2);
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

protected void addCommments(Object obj)
  throws SAXException {
  if (isMappingMode() && !isMetaDataMode()) {
    if (obj instanceof ClassMapping)
      obj = ((ClassMapping) obj).getMappingInfo();
    else if (obj instanceof FieldMapping)
      obj = ((FieldMapping) obj).getMappingInfo();
  }
  super.addComments(obj);
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

@Override
protected void serializeClass(ClassMetaData meta, boolean access)
  throws SAXException {
  if (_sync && isMappingMode() && meta instanceof ClassMapping) {
    // sync if resolved and mapped
    ClassMapping cls = (ClassMapping) meta;
    if ((cls.getResolve() & MODE_MAPPING) != 0 && cls.isMapped()) {
      cls.syncMappingInfo();
      cls.getDiscriminator().syncMappingInfo();
      cls.getVersion().syncMappingInfo();
      FieldMapping[] fields;
      if (cls.getEmbeddingMetaData() == null)
        fields = cls.getDefinedFieldMappings();
      else
        fields = cls.getFieldMappings();
      for (FieldMapping f : fields)
        f.syncMappingInfo();
    }
  }
  super.serializeClass(meta, access);
}

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

return;
if (SequenceMapping.IMPL_VALUE_TABLE.equals(meta.getSequencePlugin())) {
  super.serializeSequence(meta);
  return;

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

Log log = getLog();
if (log.isInfoEnabled())
  log.info(_loc.get("ser-class", meta));
addComments(meta);
addAttribute("class", getClassName(meta.getDescribedType().
  getName()));
if (isMetaDataMode()
  && !meta.getTypeAlias().equals(ClassUtil.getClassName(meta.
  getDescribedType())))
  addAttribute("name", meta.getTypeAlias());
String name = getEntityElementName(meta);
if (isMetaDataMode())
  addClassAttributes(meta, access);
if (isMappingMode())
  addClassMappingAttributes(meta);
startElement(name);
if (isMappingMode())
  serializeClassMappingContent(meta);
if (isMetaDataMode())
  serializeIdClass(meta);
if (isMappingMode())
  serializeInheritanceContent(meta);
if (isMappingMode()) {
  List seqs = (_seqs == null) ? null : _seqs.get

代码示例来源:origin: org.apache.openjpa/openjpa-all

addComments(fmd);
addAttribute("name", fmd.getName());
PersistenceStrategy strat = getStrategy(fmd);
ValueMetaData cascades = null;
if (fmd.isPrimaryKey() && strat == PersistenceStrategy.EMBEDDED)
      break;
    case BASIC:
      if (isMetaDataMode())
        addBasicAttributes(fmd);
      strategy = "basic";
      break;
      break;
    case MANY_ONE:
      if (isMetaDataMode())
        addManyToOneAttributes(fmd);
      strategy = "many-to-one";
      cascades = fmd;
      break;
    case ONE_ONE:
      if (isMetaDataMode())
        addOneToOneAttributes(fmd);
      strategy = "one-to-one";
      cascades = fmd;
      break;
    case ONE_MANY:
      if (isMetaDataMode())

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

for (Iterator it = objects.iterator(); it.hasNext();) {
  meta = it.next();
  switch (type(meta)) {
    case TYPE_META:
      ClassMetaData cls = (ClassMetaData) meta;
      if (unique && getPackage() == null)
        setPackage(getPackage(meta));
      else if (unique) {
        unique = getPackage().equals(getPackage(meta));
        if (!unique)
          setPackage(null);
serializeNamespaceAttributes();
startElement("entity-mappings");
if (getPackage() != null) {
  startElement("package");
  addText(getPackage());
  endElement("package");
  int def = getConfiguration().getMetaDataRepositoryInstance().
    getMetaDataFactory().getDefaults().getDefaultAccessType();
  String access = null;
    access = "PROPERTY";
  if (access != null) {
    startElement("access");
    addText(access);
    endElement("access");

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

/**
 * Serialize query metadata.
 */
private void serializeQuery(QueryMetaData meta)
  throws SAXException {
  if (!_annos && meta.getSourceType() == meta.SRC_ANNOTATIONS)
    return;
  Log log = getLog();
  if (log.isInfoEnabled()) {
    if (meta.getSourceScope() instanceof Class)
      log.info(_loc.get("ser-cls-query",
        meta.getSourceScope(), meta.getName()));
    else
      log.info(_loc.get("ser-query", meta.getName()));
  }
  addComments(meta);
  addAttribute("name", meta.getName());
  addAttribute("query", meta.getQueryString());
  if (QueryLanguages.LANG_SQL.equals(meta.getLanguage())) {
    if (meta.getResultType() != null)
      addAttribute("result-class", meta.getResultType().getName());
    startElement("named-native-query");
    serializeQueryHints(meta);
    endElement("named-native-query");
  } else {
    startElement("named-query");
    serializeQueryHints(meta);
    endElement("named-query");
  }
}

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

/**
 * Add one-to-many attributes.
 */
private void addOneToManyAttributes(FieldMetaData fmd)
  throws SAXException {
  if (fmd.isInDefaultFetchGroup())
    addAttribute("fetch", "EAGER");
  addTargetEntityAttribute(fmd);
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

/**
 * Serialize namespace attributes
 */
private void serializeNamespaceAttributes()
  throws SAXException {
  addAttribute("xmlns", "http://java.sun.com/xml/ns/persistence/orm");
  addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
  addAttribute("xsi:schemaLocation",
    "http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd");
  addAttribute("version", "2.0");
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

public int compare(Object o1, Object o2) {
  FieldMetaData fmd1 = (FieldMetaData) o1;
  FieldMetaData fmd2 = (FieldMetaData) o2;
  if (fmd1.isPrimaryKey()) {
    if (fmd2.isPrimaryKey())
      return fmd1.compareTo(fmd2);
    return -1;
  }
  if (fmd2.isPrimaryKey())
    return 1;
  if (fmd1.isVersion()) {
    if (fmd2.isVersion())
      return compareListingOrder(fmd1, fmd2);
    return getStrategy(fmd2) == PersistenceStrategy.BASIC ? 1 : -1;
  }
  if (fmd2.isVersion())
    return getStrategy(fmd1) == PersistenceStrategy.BASIC ? -1 : 1;
  int stcmp = getStrategy(fmd1).compareTo(getStrategy(fmd2));
  if (stcmp != 0)
    return stcmp;
  return compareListingOrder(fmd1, fmd2);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com