Class Wette

java.lang.Object
net.bjmsw.hda.vs.model.db.Wette

public class Wette extends Object
Represents a betting object.

Works like a simple mini ORM.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
     
    private final WettAngebot
     
    private double
     
    private final long
     
    private int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Wette(long id, WettAngebot originalAngebot, long wetterId, double wetteinsatz, int wetter_tipp)
    Creates a new Wette object with the specified parameters.
     
    Wette(WettAngebot originalAngebot, long wetterId, double wetteinsatz, int wetter_tipp)
    Creates a new Wette object with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Wette
    fromDB(long id)
    Retrieves a Wette object from the database based on the provided ID.
    static List<Wette>
    Retrieves a list of all Wette objects from the database.
    static List<Wette>
    getAllForBuchmacher(long buchmacherID)
    Retrieves a list of all Wette objects associated with a given BuchmacherID from the database.
    static List<Wette>
    getAllForWetter(long wetterID)
    Retrieves a list of all Wette objects associated with a given WetterID from the database.
    long
    Gets the ID of the Wette.
    Gets the original WettAngebot associated with the Wette.
    double
    Gets the amount of the Wetteinsatz.
    long
    Gets the ID of the Wetter who placed the Wette.
    int
    Gets the wetter tipp associated with the Wette.
    void
    Inserts a new Wette object into the database.
    boolean
    Checks if the Wette object is already in the database.
    private static List<Wette>
    Retrieves a list of Wette objects from the database based on the provided SQL statement.
    void
    updateBuchmacher(long buchmacherID)
    Updates the buchmacher_id of a Wette in the database with the provided ID.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • originalAngebot

      private final WettAngebot originalAngebot
    • wetterId

      private final long wetterId
    • id

      private long id
    • wetteinsatz

      private double wetteinsatz
    • wetterTipp

      private int wetterTipp
  • Constructor Details

    • Wette

      private Wette(long id, WettAngebot originalAngebot, long wetterId, double wetteinsatz, int wetter_tipp)
      Creates a new Wette object with the specified parameters.

      This is a private constructor that initializes the Wette object with the given parameters from the database.

      Parameters:
      id - The ID of the Wette.
      originalAngebot - The original WettAngebot associated with the Wette.
      wetterId - The ID of the Wetter who placed the Wette.
      wetteinsatz - The amount of the Wetteinsatz.
      wetter_tipp - The wetter tipp associated with the Wette.
    • Wette

      public Wette(WettAngebot originalAngebot, long wetterId, double wetteinsatz, int wetter_tipp)
      Creates a new Wette object with the specified parameters.

      This is the public constructor that initializes the Wette object with the given parameters.

      Parameters:
      originalAngebot - The original WettAngebot associated with the Wette.
      wetterId - The ID of the Wetter who placed the Wette.
      wetteinsatz - The amount of the Wetteinsatz.
      wetter_tipp - The wetter tipp associated with the Wette.
  • Method Details

    • fromDB

      public static Wette fromDB(long id)
      Retrieves a Wette object from the database based on the provided ID.
      Parameters:
      id - The ID of the Wette to retrieve.
      Returns:
      The Wette object retrieved from the database, or null if no matching Wette is found.
    • getAllForBuchmacher

      public static List<Wette> getAllForBuchmacher(long buchmacherID)
      Retrieves a list of all Wette objects associated with a given BuchmacherID from the database.
      Parameters:
      buchmacherID - The ID of the Buchmacher for which to retrieve the Wette objects.
      Returns:
      A list of Wette objects associated with the specified BuchmacherID, or null if an error occurs during retrieval.
    • getAllForWetter

      public static List<Wette> getAllForWetter(long wetterID)
      Retrieves a list of all Wette objects associated with a given WetterID from the database.
      Parameters:
      wetterID - The ID of the Wetter for which to retrieve the Wette objects.
      Returns:
      A list of Wette objects associated with the specified WetterID, or null if an error occurs during retrieval.
    • getAll

      public static List<Wette> getAll()
      Retrieves a list of all Wette objects from the database.
      Returns:
      A list of all Wette objects retrieved from the database, or null if an error occurs during retrieval.
    • sqlFromDb

      private static List<Wette> sqlFromDb(PreparedStatement statement) throws SQLException
      Retrieves a list of Wette objects from the database based on the provided SQL statement.
      Parameters:
      statement - The PreparedStatement object containing the SQL statement.
      Returns:
      A list of Wette objects retrieved from the database.
      Throws:
      SQLException - If an error occurs during the database query.
    • insert

      public void insert()
      Inserts a new Wette object into the database.

      If the ID of the Wette is already set (-1 indicates a new Wette), an error message will be logged and the method will return without inserting the Wette. Otherwise, the Wette will be inserted into the database using the provided SQL statement. The generated key for the inserted Wette will be retrieved and set as the ID of the Wette object. Errors that occur during the insertion process will be logged.

    • updateBuchmacher

      public void updateBuchmacher(long buchmacherID) throws SQLException
      Updates the buchmacher_id of a Wette in the database with the provided ID. If the Wette is not found in the database, an error message will be logged and the method will return.
      Parameters:
      buchmacherID - The new buchmacher_id to update for the Wette.
      Throws:
      SQLException - If an error occurs during the database update.
    • getWetterId

      public long getWetterId()
      Gets the ID of the Wetter who placed the Wette.
      Returns:
      The ID of the Wetter who placed the Wette.
    • getOriginalAngebot

      public WettAngebot getOriginalAngebot()
      Gets the original WettAngebot associated with the Wette.
      Returns:
      The original WettAngebot associated with the Wette.
    • getId

      public long getId()
      Gets the ID of the Wette.
      Returns:
      The ID of the Wette.
    • getWetteinsatz

      public double getWetteinsatz()
      Gets the amount of the Wetteinsatz.
      Returns:
      The amount of the Wetteinsatz.
    • getWetterTipp

      public int getWetterTipp()
      Gets the wetter tipp associated with the Wette.
      Returns:
      The wetter tipp associated with the Wette.
    • isInDB

      public boolean isInDB()
      Checks if the Wette object is already in the database.
      Returns:
      true if the Wette is in the database, false otherwise.