Class DBObject

java.lang.Object
overit.geocall.sql.DBObject
All Implemented Interfaces:
DBObjectMap

public class DBObject extends Object implements DBObjectMap
The object realizes the memorization of a DB SQL object. It implements DBObjectMap, so has the map properties for the memorization; furthermore has a member variable that will be properly transformed in the statement saving phase.
  • Field Details

    • _type

      protected int _type
      SQL type extract from the constants Types
    • _o

      protected Object _o
      Instance readed directly from the DB
  • Constructor Details

    • DBObject

      public DBObject(Object o, int type)
      Creates the object starting from a Java object and a type (Types) that defines the save mode
      Parameters:
      o - The Java object
      type - The SQL type
  • Method Details

    • getObject

      public Object getObject()
      Returns the Java object instance
      Returns:
      The Java object instance
    • getType

      public int getType()
      Returs the type (Types) with which the object was instantiated
      Returns:
      The type with which the object was instantiated
    • setObject

      public void setObject(Object o)
      Sets the content (the Java object) of the instance
      Parameters:
      o - The Java object to set
    • setType

      public void setType(int type)
      Sets the type (Types)
      Parameters:
      type - The SQL type that defines the save mode
    • loadInstance

      public Object loadInstance(ResultSet rs, int field) throws SQLException
      Loads the Java content of the instance and its SQL type from the ResultSet and the ResultSetMetaData
      Specified by:
      loadInstance in interface DBObjectMap
      Parameters:
      rs - The reading source
      field - The field from which read
      Returns:
      FReturns itself with the new contents readed from the DB
      Throws:
      SQLException - If an error occurs during the reading from the DB, an SQLException will be raised
    • saveInstance

      public void saveInstance(PreparedStatement ps, int field, Object o) throws SQLException
      Registers the instance of the object passed (that mus always be a DBObject) in a PreparedStatement
      Specified by:
      saveInstance in interface DBObjectMap
      Parameters:
      ps - The PreparedStatement on which register the object
      field - The field of the PreparedStatement
      o - The object to save
      Throws:
      SQLException - If an error occurs during the writing on the PreparedStatement, an SQLException will be raised
    • toString

      public String toString()
      Returns the string representation of the DBObject
      Overrides:
      toString in class Object
      Returns:
      The string representation of the DBObject