Add read-only user repository
Problem Context
For the reporting module, we need a read-only repository that prevents accidental writes to the database.
Advanced
200 points
File Changes (1)
src/main/java/com/example/repository/ReadOnlyUserRepository.java
ADDED
@@ -0 +1 @@
| 1 | +package com.example.repository; |
|
| 2 | + |
|
| 3 | +@Repository |
|
| 4 | +public class ReadOnlyUserRepository extends UserRepository { |
|
| 5 | + |
|
| 6 | + @Override |
|
| 7 | + public User save(User user) { |
|
| 8 | + throw new UnsupportedOperationException("This is a read-only repository"); |
|
| 9 | + } |
|
| 10 | + |
|
| 11 | + @Override |
|
| 12 | + public void delete(User user) { |
|
| 13 | + throw new UnsupportedOperationException("This is a read-only repository"); |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + @Override |
|
| 17 | + public void deleteById(Long id) { |
|
| 18 | + throw new UnsupportedOperationException("This is a read-only repository"); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + @Override |
|
| 22 | + public List<User> saveAll(List<User> users) { |
|
| 23 | + throw new UnsupportedOperationException("This is a read-only repository"); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + // Read operations inherited from parent work fine |
|
| 27 | +} |
Login Required: You must be registered to submit reviews and receive AI feedback.
Register or
login to start reviewing!
Your Review
Review Tips
- Look for security vulnerabilities (SQL injection, XSS, etc.)
- Check for null pointer exceptions and error handling
- Consider performance implications
- Evaluate code maintainability and readability
- Check for proper resource management
- Look for logic errors or edge cases