Class BioSQLRichObjectBuilder

  • All Implemented Interfaces:
    RichObjectBuilder

    public class BioSQLRichObjectBuilder
    extends Object
    implements RichObjectBuilder
    Takes requests for RichObjects and sees if it can load them from a Hibernate database. If it can, it returns the loaded objects. Else, it creates them and persists them, then returns them. Doesn't retain a memory map so runs a lot of Hibernate queries if used frequently, but on the plus side this makes it memory-efficient.
    Since:
    1.5
    Author:
    Richard Holland, David Scott, Deepak Sheoran
    • Constructor Detail

      • BioSQLRichObjectBuilder

        public BioSQLRichObjectBuilder​(Object session)
        Creates a new instance of SimpleRichObjectBuilder. The session parameter is a Hibernate Session object and must not be null. It is this session that database objects will be retrieved from/persisted to.
        See Also:
        org.hibernate.Session
    • Method Detail

      • buildObject

        public Object buildObject​(Class clazz,
                                  List paramsList)
        This method takes a class name and some parameters, and uses that information to construct and return an equivalent object, usually by calling the constructor on the class with the supplied parameters. Note that it only works with classes whose constructors take only Objects, and not primitives. It should return singletons. Attempts to look up the details of the object in the database. If it finds them it loads the object and returns it. Else, it persists the wrapper object it made to do the search with and returns that.
        Specified by:
        buildObject in interface RichObjectBuilder
        Parameters:
        clazz - the class to instantiate and build
        paramsList - the parameters to pass to the constructor
        Returns:
        an instance of the requested class/params combination. May or may not be a singleton, but usually will be given as that is the purpose of this class.