Class ComponenteDAO


  • public class ComponenteDAO
    extends BaseDAO<Componente>
    Data Access Object for the Componentes table Handles database operations for component entities
    • Constructor Summary

      Constructors 
      Constructor Description
      ComponenteDAO()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean existsByModelo​(java.lang.String modelo)
      Checks if a component with the given model name already exists
      Componente findByModelo​(java.lang.String modelo)
      Finds a component by its model name
      protected java.lang.String[] getColumnNames()
      Gets the column names for the Componentes table
      int getIdByModelo​(java.lang.String modelo)
      Retrieves the ID of a component by its model name
      protected java.lang.String getTableName()
      Gets the name of the database table
      protected Componente mapResultSetToEntity​(java.sql.ResultSet rs)
      Maps a ResultSet row to a Componente entity
      protected void setPreparedStatementParams​(java.sql.PreparedStatement ps, Componente entity)
      Sets the parameters for a PreparedStatement based on Componente properties
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ComponenteDAO

        public ComponenteDAO()
    • Method Detail

      • getTableName

        protected java.lang.String getTableName()
        Gets the name of the database table
        Specified by:
        getTableName in class BaseDAO<Componente>
        Returns:
        The table name "componentes"
      • getColumnNames

        protected java.lang.String[] getColumnNames()
        Gets the column names for the Componentes table
        Specified by:
        getColumnNames in class BaseDAO<Componente>
        Returns:
        Array of column names
      • mapResultSetToEntity

        protected Componente mapResultSetToEntity​(java.sql.ResultSet rs)
                                           throws java.sql.SQLException
        Maps a ResultSet row to a Componente entity
        Specified by:
        mapResultSetToEntity in class BaseDAO<Componente>
        Parameters:
        rs - The ResultSet containing the database row
        Returns:
        A new Componente object with data from the ResultSet
        Throws:
        java.sql.SQLException - if a database error occurs
      • setPreparedStatementParams

        protected void setPreparedStatementParams​(java.sql.PreparedStatement ps,
                                                  Componente entity)
                                           throws java.sql.SQLException
        Sets the parameters for a PreparedStatement based on Componente properties
        Specified by:
        setPreparedStatementParams in class BaseDAO<Componente>
        Parameters:
        ps - The PreparedStatement to set parameters for
        entity - The Componente entity containing the values to set
        Throws:
        java.sql.SQLException - if a database error occurs
      • getIdByModelo

        public int getIdByModelo​(java.lang.String modelo)
                          throws java.sql.SQLException
        Retrieves the ID of a component by its model name
        Parameters:
        modelo - The model name of the component
        Returns:
        The ID of the component, or -1 if not found
        Throws:
        java.sql.SQLException - if a database error occurs
      • findByModelo

        public Componente findByModelo​(java.lang.String modelo)
                                throws java.sql.SQLException
        Finds a component by its model name
        Parameters:
        modelo - The model name to search for
        Returns:
        The Componente object if found, null otherwise
        Throws:
        java.sql.SQLException - if a database error occurs
      • existsByModelo

        public boolean existsByModelo​(java.lang.String modelo)
                               throws java.sql.SQLException
        Checks if a component with the given model name already exists
        Parameters:
        modelo - The model name of the component to check
        Returns:
        true if a component with the model name exists, false otherwise
        Throws:
        java.sql.SQLException - if a database error occurs