-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaymentDao.java
More file actions
67 lines (59 loc) · 2.08 KB
/
PaymentDao.java
File metadata and controls
67 lines (59 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
public class PaymentDao {
private static final Logger logger = LoggerFactory.getLogger(PaymentDao.class);
private final Session session;
public PaymentDao(Session session) {
this.session = session;
}
/**
* Saves the given {@link Payment} in the database.
*
* @param payment the {@link Payment} to save
* @throws HibernateException if an error occurs while saving the payment
* @throws IllegalArgumentException if payment is null
*/
public void save(Payment payment) {
if (payment == null) {
throw new IllegalArgumentException("Payment cannot be null");
}
try {
Transaction transaction = session.beginTransaction();
session.save(payment);
transaction.commit();
logger.info("Payment saved successfully");
} catch (Exception e) {
logger.error("Error occurred while saving payment: " + e.getMessage());
}
}
/**
* Updates the given Payment object in the database.
*
* @param payment The Payment object to be updated.
* @throws HibernateException If an error occurs while updating the payment.
*/
public void update(Payment payment) {
try {
Transaction transaction = session.beginTransaction();
session.update(payment);
transaction.commit();
logger.info("Payment updated successfully");
} catch (Exception e) {
logger.error("Error occurred while updating payment: " + e.getMessage());
}
}
/**
* Retrives the {@link Payment} from the database transactionally.
*
* @param paymentId the {@link Payment} to update
* @throws HibernateException if an error occurs while saving the payment
*/
public Payment get(String id) {
}
/**
* Deletes the given {@link Payment} to the database.
*
* @param payment the {@link Payment} to update
* @throws HibernateException if an error occurs while saving the payment
*/
public void delete(Payment payment) {
}
}