Package net.bjmsw.hda.vs.model.db
Class WettAngebot
java.lang.Object
net.bjmsw.hda.vs.model.db.WettAngebot
Represents a betting offer.
Works like a simple mini ORM.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) long(package private) long(package private) double(package private) double(package private) double(package private) long -
Constructor Summary
ConstructorsConstructorDescriptionWettAngebot(long spielId, long userId, double team0quote, double team1quote, double team2quote) Represents a betting offer. -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()Deletes the current betting offer from the database.static WettAngebotfromDB(long id) Retrieves a betting offer from the database based on the provided ID.static Map<Long,WettAngebot> getAll()Retrieves all betting offers from the database.static Map<Long,WettAngebot> getAllForBuchmacher(long buchmacherID) Retrieves all betting offers associated with a specific bookmaker from the database.static Map<Long,WettAngebot> getAllForSpiel(long spielId) Retrieves all betting offers associated with a specific game from the database.longgetId()Gets the ID of the betting offer.longGets the ID of the game associated with the betting offer.doubleGets the quote for team 0.doubleGets the quote for team 1.doubleGets the quote for team 2.longGets the ID of the user who placed the betting offer.voidinsert()Inserts a new betting offer into the database.booleanisInDb()Checks if the betting offer is already in the database.private static Map<Long,WettAngebot> sqlFromDb(PreparedStatement statement) Retrieves a map of betting offers from the database based on the provided SQL statement.
-
Field Details
-
id
long id -
spielId
long spielId -
userId
long userId -
team0quote
double team0quote -
team1quote
double team1quote -
team2quote
double team2quote
-
-
Constructor Details
-
WettAngebot
public WettAngebot(long spielId, long userId, double team0quote, double team1quote, double team2quote) Represents a betting offer.- Parameters:
spielId- the ID of the game associated with the offeruserId- the ID of the user who placed the offerteam0quote- the quote for team 0team1quote- the quote for team 1team2quote- the quote for team 2
-
-
Method Details
-
insert
public void insert()Inserts a new betting offer into the database. -
fromDB
Retrieves a betting offer from the database based on the provided ID.- Parameters:
id- The ID of the betting offer to retrieve from the database.- Returns:
- The retrieved betting offer, or null if it doesn't exist or an error occurs.
-
getAll
Retrieves all betting offers from the database.- Returns:
- A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects. Returns null if an error occurs.
-
getAllForSpiel
Retrieves all betting offers associated with a specific game from the database.- Parameters:
spielId- The ID of the game to retrieve the betting offers for.- Returns:
- A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects. Returns null if an error occurs.
-
getAllForBuchmacher
Retrieves all betting offers associated with a specific bookmaker from the database.- Parameters:
buchmacherID- The ID of the bookmaker to retrieve the betting offers for.- Returns:
- A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects. Returns null if an error occurs during retrieval.
-
sqlFromDb
Retrieves a map of betting offers from the database based on the provided SQL statement.- Parameters:
statement- The prepared statement used to execute the SQL query.- Returns:
- A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects.
- Throws:
SQLException- If an error occurs during the execution of the SQL query.
-
delete
public void delete()Deletes the current betting offer from the database.This method deletes the current betting offer from the database by executing an SQL DELETE statement. The betting offer to be deleted is determined based on the ID of the current object.
- Throws:
SQLException- If an error occurs during the execution of the SQL statement.
-
getTeam0Quote
public double getTeam0Quote()Gets the quote for team 0.- Returns:
- The quote for team 0.
-
getTeam1Quote
public double getTeam1Quote()Gets the quote for team 1.- Returns:
- The quote for team 1.
-
getTeam2Quote
public double getTeam2Quote()Gets the quote for team 2.- Returns:
- The quote for team 2.
-
getId
public long getId()Gets the ID of the betting offer.- Returns:
- The ID of the betting offer.
-
getSpielId
public long getSpielId()Gets the ID of the game associated with the betting offer.- Returns:
- The ID of the game associated with the betting offer.
-
getUserId
public long getUserId()Gets the ID of the user who placed the betting offer.- Returns:
- The ID of the user who placed the betting offer.
-
isInDb
public boolean isInDb()Checks if the betting offer is already in the database.- Returns:
- true if the betting offer is in the database, false otherwise.
-