Class StaxXMLEntityConverter

  • All Implemented Interfaces:
    OBNotSingleton, OBProvidable

    public class StaxXMLEntityConverter
    extends BaseXMLEntityConverter
    implements OBNotSingleton
    Converts a XML string to an objectgraph with objects using a Stax approach. It can handle very large XML Documents (> 500mb). It can not handle OneToMany properties, for this the XMLEntityConverter should be used. The StaxXMLEntityConverter is mainly used for client import and export which has larger datasets. During the XML parse phase this converter will match XML tags with new or existing (in the database) business objects. The matching logic is implemented in the EntityResolver.

    The XMLEntityConverter keeps track of which objects are new, which exist but do not need to be updated or which objects exist but need to be updated.

    This converter does not update the database directly. However, it changes the properties of existing objects. This means that a commit after calling the process method on the converter can result in database updates by Hibernate.

    Author:
    mtaal
    See Also:
    Entity
    • Constructor Detail

      • StaxXMLEntityConverter

        public StaxXMLEntityConverter()
    • Method Detail

      • process

        public List<BaseOBObject> process​(Reader reader)
        The main entry point. This method creates a XMLStreamReader and then calls process(XMLStreamReader).
        Parameters:
        reader - the xml
        Returns:
        the list of BaseOBObject present in the root of the xml. This list contains the to-be-updated, to-be-inserted as well as the unchanged business objects
      • process

        public List<BaseOBObject> process​(XMLStreamReader xmlReader)
        The main entry point. This method walks through the elements in the root and parses them. The children of a business object (in the xml) are also parsed. Referenced objects are resolved through the EntityResolver.

        After a call to this method the to-be-inserted objects can be retrieved through the BaseXMLEntityConverter.getToInsert() method and the to-be-updated objects through the BaseXMLEntityConverter.getToUpdate() method.

        Parameters:
        xmlReader - the xml to parse
        Returns:
        the list of BaseOBObject present in the root of the xml. This list contains the to-be-updated, to-be-inserted as well as the unchanged business objects