Package net.bjmsw.hda.vs.model.db
Class Wette
java.lang.Object
net.bjmsw.hda.vs.model.db.Wette
Represents a betting object.
Works like a simple mini ORM.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate final WettAngebotprivate doubleprivate final longprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateWette(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 TypeMethodDescriptionstatic WettefromDB(long id) Retrieves a Wette object from the database based on the provided ID.getAll()Retrieves a list of all Wette objects from the database.getAllForBuchmacher(long buchmacherID) Retrieves a list of all Wette objects associated with a given BuchmacherID from the database.getAllForWetter(long wetterID) Retrieves a list of all Wette objects associated with a given WetterID from the database.longgetId()Gets the ID of the Wette.Gets the original WettAngebot associated with the Wette.doubleGets the amount of the Wetteinsatz.longGets the ID of the Wetter who placed the Wette.intGets the wetter tipp associated with the Wette.voidinsert()Inserts a new Wette object into the database.booleanisInDB()Checks if the Wette object is already in the database.sqlFromDb(PreparedStatement statement) Retrieves a list of Wette objects from the database based on the provided SQL statement.voidupdateBuchmacher(long buchmacherID) Updates the buchmacher_id of a Wette in the database with the provided ID.
-
Field Details
-
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
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
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
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
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
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
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
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
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.
-